function isUniqueUser($id) { $ppslf = TTnew('PayPeriodScheduleListFactory'); $ph = array('id' => $id); $query = 'select a.id from ' . $this->getTable() . ' as a, ' . $ppslf->getTable() . ' as b where a.pay_period_schedule_id = b.id AND a.user_id = ? AND b.deleted=0'; $user_id = $this->db->GetOne($query, $ph); Debug::Arr($user_id, 'Unique User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); if ($user_id === FALSE) { return TRUE; } return FALSE; }
function isUniqueUser($id) { $pclf = new PermissionControlListFactory(); $ph = array('id' => $id); $query = 'select a.id from ' . $this->getTable() . ' as a, ' . $pclf->getTable() . ' as b where a.permission_control_id = b.id AND a.user_id = ? AND b.deleted=0'; $user_id = $this->db->GetOne($query, $ph); Debug::Arr($user_id, 'Unique User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); if ($user_id === FALSE) { return TRUE; } return FALSE; }
function isUniqueName($name) { $ph = array('name' => $name); $query = 'select id from ' . $this->getTable() . ' where name = ?'; $name_id = $this->db->GetOne($query, $ph); Debug::Arr($name_id, 'Unique Name: ' . $name, __FILE__, __LINE__, __METHOD__, 10); if ($name_id === FALSE) { return TRUE; } else { if ($name_id == $this->getId()) { return TRUE; } } return FALSE; }
function isUnique($company_id, $id) { $ph = array('company_id' => (int) $company_id, 'id' => (int) $id); $query = 'select id from ' . $this->getTable() . ' where company_id = ? AND id != ? AND deleted=0'; $id = $this->db->GetOne($query, $ph); Debug::Arr($company_id, 'Company ID: ' . $company_id . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); if ($id === FALSE) { return TRUE; } else { if ($id == $this->getId()) { return TRUE; } } return FALSE; }
function isUniqueName($name) { $ph = array('company_id' => $this->getCompany(), 'name' => $name); $query = 'select id from ' . $this->getTable() . ' where company_id = ? AND name = ? AND deleted = 0'; $hierarchy_control_id = $this->db->GetOne($query, $ph); Debug::Arr($hierarchy_control_id, 'Unique Hierarchy Control ID: ' . $hierarchy_control_id, __FILE__, __LINE__, __METHOD__, 10); if ($hierarchy_control_id === FALSE) { return TRUE; } else { if ($hierarchy_control_id == $this->getId()) { return TRUE; } } return FALSE; }
function Done() { Debug::Arr($this->tmp_data, 'Pay Stub TMP Data: ', __FILE__, __LINE__, __METHOD__, 10); //Call pre-save() first, so calculates the totals. $this->setEnableCalcTotal(TRUE); $this->preSave(); if ($this->Validate()) { $this->CommitTransaction(); //$this->FailTransaction(); return TRUE; } $this->FailTransaction(); //Fails Transaction $this->CommitTransaction(); //Rollback occurs here. This is important when looping over many employees that may have a pay stub that fails. return FALSE; }
/** * Smarty plugin * @package Smarty * @subpackage plugins */ function smarty_function_EmbeddedAuthorizationList($params, &$smarty) { global $current_company, $current_user; $object_type_id = $params['object_type_id']; $object_id = $params['object_id']; $ulf = new UserListFactory(); $hlf = new HierarchyListFactory(); $hotlf = new HierarchyObjectTypeListFactory(); $alf = new AuthorizationListFactory(); $alf->setObjectType($object_type_id); //$authorizing_obj = $alf->getObjectHandler()->getById( $object_id )->getCurrent(); $tmp_authorizing_obj = $alf->getObjectHandler()->getById($object_id); if (is_object($tmp_authorizing_obj)) { $authorizing_obj = $tmp_authorizing_obj->getCurrent(); } else { return FALSE; } //var_dump($authorizing_obj); unset($alf); $user_id = $authorizing_obj->getUserObject()->getId(); $alf = new AuthorizationListFactory(); $alf->getByObjectTypeAndObjectId($object_type_id, $object_id); foreach ($alf as $authorization_obj) { $authorization_data[] = array('id' => $authorization_obj->getId(), 'created_by_full_name' => $ulf->getById($authorization_obj->getCreatedBy())->getCurrent()->getFullName(), 'authorized' => $authorization_obj->getAuthorized(), 'created_date' => $authorization_obj->getCreatedDate(), 'created_by' => $authorization_obj->getCreatedBy(), 'updated_date' => $authorization_obj->getUpdatedDate(), 'updated_by' => $authorization_obj->getUpdatedBy(), 'deleted_date' => $authorization_obj->getDeletedDate(), 'deleted_by' => $authorization_obj->getDeletedBy()); $user_id = $authorization_obj->getCreatedBy(); } if ($authorizing_obj->getStatus() == 30) { //If the object is still pending authorization, display who its waiting on... $hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($current_company->getId(), $object_type_id)->getCurrent()->getHierarchyControl(); Debug::Text('Hierarchy ID: ' . $hierarchy_id, __FILE__, __LINE__, __METHOD__, 10); //Get Parents $parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $user_id); Debug::Arr($parent_level_user_ids, 'Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10); if ($parent_level_user_ids !== FALSE and count($parent_level_user_ids) > 0) { Debug::Text('Adding Pending Line: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($parent_level_user_ids as $parent_user_id) { $created_by_full_name[] = $ulf->getById($parent_user_id)->getCurrent()->getFullName(); } $authorization_data[] = array('id' => NULL, 'created_by_full_name' => implode('<br>', $created_by_full_name), 'authorized' => NULL, 'created_date' => NULL, 'created_by' => NULL); } } $smarty->assign_by_ref('authorization_data', $authorization_data); $smarty->display('authorization/EmbeddedAuthorizationList.tpl'); }
function Send() { Debug::Text('Attempting to send email To: ' . $this->getTo(), __FILE__, __LINE__, __METHOD__, 10); if ($this->getTo() == FALSE) { Debug::Text('To Address invalid...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if ($this->getBody() == FALSE) { Debug::Text('Body invalid...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } Debug::Text('Sending Email To: ' . $this->getTo() . ' Body Size: ' . strlen($this->getBody()) . ' Method: ' . $this->getDeliveryMethod(), __FILE__, __LINE__, __METHOD__, 10); if (PRODUCTION == FALSE) { Debug::Text('Not in production mode, not sending emails...', __FILE__, __LINE__, __METHOD__, 10); //$to = 'root@localhost'; return FALSE; } if (DEMO_MODE == TRUE) { Debug::Text('In DEMO mode, not sending emails...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } switch ($this->getDeliveryMethod()) { case 'smtp': case 'mail': $send_retval = $this->getMailObject()->send($this->getTo(), $this->getMIMEHeaders(), $this->getBody()); if (PEAR::isError($send_retval)) { Debug::Text('Send Email Failed... Error: ' . $send_retval->getMessage(), __FILE__, __LINE__, __METHOD__, 10); $send_retval = FALSE; } break; case 'soap': $ttsc = new TimeTrexSoapClient(); $send_retval = $ttsc->sendEmail($this->getTo(), $this->getMIMEHeaders(), $this->getBody()); break; } if ($send_retval == TRUE) { return TRUE; } Debug::Arr($send_retval, 'Send Email Failed!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
$pay_period_options = array(); } if (isset($filter_data['start_date'])) { $filter_data['start_date'] = TTDate::parseDateTime($filter_data['start_date']); } if (isset($filter_data['end_date'])) { $filter_data['end_date'] = TTDate::parseDateTime($filter_data['end_date']); } $filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'user_title_ids', 'pay_period_ids', 'column_ids'), array()); //Get Permission Hierarchy Children first, as this can be used for viewing, or editing. $permission_children_ids = array(); $wage_permission_children_ids = array(); if ($permission->Check('punch', 'view') == FALSE) { $hlf = TTnew('HierarchyListFactory'); $permission_children_ids = $wage_permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($current_company->getId(), $current_user->getId()); Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10); if ($permission->Check('punch', 'view_child') == FALSE) { $permission_children_ids = array(); } if ($permission->Check('punch', 'view_own')) { $permission_children_ids[] = $current_user->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 ($permission->Check('wage', 'view') == FALSE) { if ($permission->Check('wage', 'view_child') == FALSE) { $wage_permission_children_ids = array(); } if ($permission->Check('wage', 'view_own')) { $wage_permission_children_ids[] = $current_user->getId();
/** * Delete one or more users. * @param array $data user data * @return array */ function deleteUser($data) { if (is_numeric($data)) { $data = array($data); } if (DEMO_MODE == TRUE) { return $this->returnHandler(TRUE); } if (!is_array($data)) { return $this->returnHandler(FALSE); } if (!$this->getPermissionObject()->Check('user', 'enabled') or !($this->getPermissionObject()->Check('user', 'delete') or $this->getPermissionObject()->Check('user', 'delete_own') or $this->getPermissionObject()->Check('user', 'delete_child'))) { return $this->getPermissionObject()->PermissionDenied(); } //Get Permission Hierarchy Children first, as this can be used for viewing, or editing. $permission_children_ids = $this->getPermissionChildren(); Debug::Text('Received data for: ' . count($data) . ' Users', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $total_records = count($data); $validator_stats = array('total_records' => $total_records, 'valid_records' => 0); if (is_array($data)) { $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_records); foreach ($data as $key => $id) { $primary_validator = new Validator(); $lf = TTnew('UserListFactory'); $lf->StartTransaction(); if (is_numeric($id)) { if ($this->getPermissionObject()->Check('company', 'view') == TRUE) { $lf->getById($id); //Allow deleting employees in other companies. } else { $lf->getByIdAndCompanyId($id, $this->getCurrentCompanyObject()->getId()); } if ($lf->getRecordCount() == 1) { //Object exists, check edit permissions //Debug::Text('User ID: '. $user['id'] .' Created By: '. $lf->getCurrent()->getCreatedBy() .' Is Owner: '. (int)$this->getPermissionObject()->isOwner( $lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID() ) .' Is Child: '. (int)$this->getPermissionObject()->isChild( $lf->getCurrent()->getId(), $permission_children_ids ), __FILE__, __LINE__, __METHOD__, 10); if ($this->getPermissionObject()->Check('user', 'delete') or $this->getPermissionObject()->Check('user', 'delete_own') and $this->getPermissionObject()->isOwner($lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID()) === TRUE or $this->getPermissionObject()->Check('user', 'delete_child') and $this->getPermissionObject()->isChild($lf->getCurrent()->getId(), $permission_children_ids) === TRUE) { Debug::Text('Record Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10); $lf = $lf->getCurrent(); } else { $primary_validator->isTrue('permission', FALSE, TTi18n::gettext('Delete permission denied')); } } else { //Object doesn't exist. $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist')); } } else { $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist')); } //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10); $is_valid = $primary_validator->isValid(); if ($is_valid == TRUE) { //Check to see if all permission checks passed before trying to save data. Debug::Text('Attempting to delete record...', __FILE__, __LINE__, __METHOD__, 10); $lf->setDeleted(TRUE); $is_valid = $lf->isValid(); if ($is_valid == TRUE) { Debug::Text('Record Deleted...', __FILE__, __LINE__, __METHOD__, 10); $save_result[$key] = $lf->Save(); $validator_stats['valid_records']++; } } if ($is_valid == FALSE) { Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10); $lf->FailTransaction(); //Just rollback this single record, continue on to the rest. if ($primary_validator->isValid() == FALSE) { $validator[$key] = $primary_validator->getErrorsArray(); } else { $validator[$key] = $lf->Validator->getErrorsArray(); } } $lf->CommitTransaction(); $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } $this->getProgressBarObject()->stop($this->getAMFMessageID()); if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) { if ($validator_stats['total_records'] == 1) { return $this->returnHandler($save_result[$key]); //Single valid record } else { return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats); //Multiple valid records } } else { return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats); } } return $this->returnHandler(FALSE); }
/** * Copy one or more UserPreferencees. * @param array $data UserPreference IDs * @return array */ function copyUserPreference($data) { if (is_numeric($data)) { $data = array($data); } if (!is_array($data)) { return $this->returnHandler(FALSE); } Debug::Text('Received data for: ' . count($data) . ' UserPreferences', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $src_rows = $this->stripReturnHandler($this->getUserPreference(array('filter_data' => array('id' => $data)), TRUE)); if (is_array($src_rows) and count($src_rows) > 0) { Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($src_rows as $key => $row) { unset($src_rows[$key]['id'], $src_rows[$key]['manual_id']); //Clear fields that can't be copied $src_rows[$key]['name'] = Misc::generateCopyName($row['name']); //Generate unique name } //Debug::Arr($src_rows, 'bSRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); return $this->setUserPreference($src_rows); //Save copied rows } return $this->returnHandler(FALSE); }
if (!$permission->Check('premium_policy', 'enabled') or !($permission->Check('premium_policy', 'view') or $permission->Check('premium_policy', 'view_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Premium Policy List')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'ids'))); URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page)); $sort_array = NULL; if ($sort_column != '') { $sort_array = array($sort_column => $sort_order); } Debug::Arr($ids, 'Selected Objects', __FILE__, __LINE__, __METHOD__, 10); $action = Misc::findSubmitButton(); switch ($action) { case 'add': Redirect::Page(URLBuilder::getURL(NULL, 'EditPremiumPolicy.php', FALSE)); break; case 'delete': case 'undelete': if (strtolower($action) == 'delete') { $delete = TRUE; } else { $delete = FALSE; } $pplf = TTnew('PremiumPolicyListFactory'); foreach ($ids as $id) { $pplf->getByIdAndCompanyId($id, $current_company->getId());
/** * Copy one or more branches. * @param array $data branch IDs * @return array */ function copyRecurringPayStubAmendment($data) { if (is_numeric($data)) { $data = array($data); } if (!is_array($data)) { return $this->returnHandler(FALSE); } Debug::Text('Received data for: ' . count($data) . ' RecurringPayStubAmendments', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $src_rows = $this->stripReturnHandler($this->getRecurringPayStubAmendment(array('filter_data' => array('id' => $data)), TRUE)); if (is_array($src_rows) and count($src_rows) > 0) { Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($src_rows as $key => $row) { unset($src_rows[$key]['id']); //Clear fields that can't be copied } //Debug::Arr($src_rows, 'bSRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); return $this->setRecurringPayStubAmendment($src_rows); //Save copied rows } return $this->returnHandler(FALSE); }
/** * Run manual commands on timeclocks * @param string $command command name * @param array $data station IDs * @return array */ function runManualCommand($command, $data) { if (is_numeric($data)) { $data = array($data); } if (!is_array($data)) { return $this->returnHandler(FALSE); } Debug::Text('Time Clock Command: ' . $command, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Received data for: ' . count($data) . ' Stations', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $src_rows = $this->stripReturnHandler($this->getStation(array('filter_data' => array('id' => $data)), TRUE)); if (is_array($src_rows) and count($src_rows) > 0) { Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($src_rows as $key => $row) { //Skip any non-timeclock types. if ($row['type_id'] < 100) { continue; } Debug::Text(' Type: ' . $row['type_id'] . ' Source: ' . $row['source'] . ' Port: ' . $row['port'] . ' Password: '******'password'], __FILE__, __LINE__, __METHOD__, 10); $tc = new TimeClock($row['type_id']); $tc->setIPAddress($row['source']); $tc->setPort($row['port']); //$tc->setUsername( $row['user_name'] ); $tc->setPassword($row['password']); $slf = TTnew('StationListFactory'); $slf->getByIdAndCompanyId($row['id'], $this->getCurrentCompanyObject()->getId()); if ($slf->getRecordCount() == 1) { $s_obj = $slf->getCurrent(); } $s_obj->setLastPunchTimeStamp($s_obj->getLastPunchTimeStamp()); if ($s_obj->getTimeZone() != '' and !is_numeric($s_obj->getTimeZone())) { Debug::text('Setting Station TimeZone To: ' . $s_obj->getTimeZone(), __FILE__, __LINE__, __METHOD__, 10); TTDate::setTimeZone($s_obj->getTimeZone()); } $result_str = NULL; switch ($command) { case 'test_connection': if ($tc->testConnection() == TRUE) { $result_str = TTi18n::gettext('Connection Succeeded!'); } else { $result_str = TTi18n::gettext('Connection Failed!'); } break; case 'set_date': TTDate::setTimeZone($row['time_zone_id'], $s_obj->getTimeZone()); if ($tc->setDate(time()) == TRUE) { $result_str = TTi18n::gettext('Date Successfully Set To: ') . TTDate::getDate('DATE+TIME', time()); } else { $result_str = TTi18n::gettext('Setting Date Failed!'); } break; case 'download': if (isset($s_obj) and $tc->Poll($this->getCurrentCompanyObject(), $s_obj) == TRUE) { $result_str = TTi18n::gettext('Download Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Download Data Failed!'); } break; case 'upload': if (isset($s_obj) and $tc->Push($this->getCurrentCompanyObject(), $s_obj) == TRUE) { $result_str = TTi18n::gettext('Upload Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Upload Data Failed!'); } break; case 'update_config': if (isset($s_obj) and $tc->setModeFlag($s_obj->getModeFlag()) == TRUE) { $result_str = TTi18n::gettext('Update Configuration Succeeded'); } else { $result_str = TTi18n::gettext('Update Configuration Failed'); } break; case 'delete_data': if (isset($s_obj) and $tc->DeleteAllData($s_obj) == TRUE) { $result_str = TTi18n::gettext('Delete Data Succeeded!'); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } } else { $result_str = TTi18n::gettext('Delete Data Failed!'); } break; case 'reset_last_punch_time_stamp': $s_obj->setLastPunchTimeStamp(time()); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } $result_str = TTi18n::gettext('Reset Last Punch Time Succeeded!'); break; case 'clear_last_punch_time_stamp': $s_obj->setLastPunchTimeStamp(1); if ($s_obj->isValid()) { $s_obj->Save(FALSE); } $result_str = TTi18n::gettext('Clear Last Punch Time Succeeded!'); break; case 'restart': $tc->restart(); $result_str = TTi18n::gettext('Restart Succeeded!'); break; case 'firmware': if ($tc->setFirmware() == TRUE) { $result_str = TTi18n::gettext('Firmware Update Succeeded!'); } else { $result_str = TTi18n::gettext('Firmware Update Failed!'); } break; default: $result_str = TTi18n::gettext('Invalid manual command!'); break; } TTLog::addEntry($s_obj->getId(), 500, TTi18n::getText('TimeClock Manual Command') . ': ' . ucwords(str_replace('_', ' ', $command)) . ' ' . TTi18n::getText('Result') . ': ' . $result_str, NULL, $s_obj->getTable()); if (isset($s_obj)) { $row['last_poll_date'] = $s_obj->getLastPollDate(); $row['last_push_date'] = $s_obj->getLastPushDate(); } unset($s_obj, $slf); } return $this->returnHandler($result_str); } return $this->returnHandler(FALSE); }
final function isValid($label = NULL) { if ($this->num_errors == 0) { return TRUE; } elseif ($label != NULL) { //Debug::text('Num Errors: '. $this->num_errors, __FILE__, __LINE__, __METHOD__, $this->verbosity); //Check to see if a single form variable is valid. if (!isset($this->errors[$label])) { return TRUE; } else { return FALSE; } } Debug::Arr($this->errors, 'Errors', __FILE__, __LINE__, __METHOD__, $this->verbosity); return FALSE; }
function saveQueue() { if (is_array($this->queue)) { Debug::Arr($this->queue, 'Generic Status Queue', __FILE__, __LINE__, __METHOD__, 10); foreach ($this->queue as $key => $queue_data) { $ugsf = new UserGenericStatusFactory(); $ugsf->setUser($this->getUser()); if ($this->getBatchId() !== FALSE) { $ugsf->setBatchID($this->getBatchID()); } else { $this->setBatchId($this->getNextBatchId()); } $ugsf->setLabel($queue_data['label']); $ugsf->setStatus($queue_data['status']); $ugsf->setDescription($queue_data['description']); $ugsf->setLink($queue_data['link']); if ($ugsf->isValid()) { $ugsf->Save(); unset($this->queue[$key]); } } return TRUE; } Debug::Text('Generic Status Queue Empty', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if (!is_array($order)) { //Use Filter Data ordering if its set. if (isset($filter_data['sort_column']) and $filter_data['sort_order']) { $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']); } } $additional_order_fields = array(); $sort_column_aliases = array(); $order = $this->getColumnsFromAliases($order, $sort_column_aliases); if ($order == NULL) { $order = array('name' => 'asc'); $strict = FALSE; } else { //Always sort by last name,first name after other columns if (!isset($order['name'])) { $order['name'] = 'asc'; } $strict = TRUE; } //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10); Debug::Arr($filter_data, 'Filter Data:', __FILE__, __LINE__, __METHOD__, 10); $uf = new UserFactory(); $ph = array('company_id' => $company_id); $query = ' select a.*, y.first_name as created_by_first_name, y.middle_name as created_by_middle_name, y.last_name as created_by_last_name, z.first_name as updated_by_first_name, z.middle_name as updated_by_middle_name, z.last_name as updated_by_last_name from ' . $this->getTable() . ' as a LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 ) LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 ) where a.company_id = ?'; if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) { $query .= ' AND a.created_by in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') '; } if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) { $query .= ' AND a.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') '; } if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) { $query .= ' AND a.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') '; } if (isset($filter_data['object_type_id']) and isset($filter_data['object_type_id'][0]) and !in_array(-1, (array) $filter_data['object_type_id'])) { $query .= ' AND a.object_type_id in (' . $this->getListSQL($filter_data['object_type_id'], $ph) . ') '; } $query .= isset($filter_data['name']) ? $this->getWhereClauseSQL('a.name', $filter_data['name'], 'text_metaphone', $ph) : NULL; $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL; $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL; $query .= ' AND a.deleted = 0 '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict, $additional_order_fields); $this->ExecuteSQL($query, $ph, $limit, $page); return $this; }
function generateData() { global $current_company, $current_user; TTDate::setTimeZone('PST8PDT'); $current_epoch = time(); $cf = new CompanyFactory(); $cf->StartTransaction(); $company_id = $this->createCompany(); $clf = new CompanyListFactory(); $clf->getById($company_id); $current_company = $clf->getCurrent(); if ($company_id !== FALSE) { Debug::Text('Company Created Successfully!', __FILE__, __LINE__, __METHOD__, 10); $this->createPermissionGroups($company_id); //Create currency $currency_ids[] = $this->createCurrency($company_id, 10); //USD $currency_ids[] = $this->createCurrency($company_id, 20); //CAD //Create branch $branch_ids[] = $this->createBranch($company_id, 10); //NY $branch_ids[] = $this->createBranch($company_id, 20); //WA //Create departments $department_ids[] = $this->createDepartment($company_id, 10); $department_ids[] = $this->createDepartment($company_id, 20); //Create stations $station_id = $this->createStation($company_id); //Create pay stub accounts. $this->createPayStubAccount($company_id); //Link pay stub accounts. $this->createPayStubAccountLink($company_id); //Company Deductions $this->createCompanyDeduction($company_id); //Wage Groups $wage_group_ids[] = $this->createUserWageGroups($company_id); //User Groups $user_group_ids[] = $this->createUserGroup($company_id, 10, 0); $user_group_ids[] = $this->createUserGroup($company_id, 20, $user_group_ids[0]); $user_group_ids[] = $this->createUserGroup($company_id, 30, $user_group_ids[0]); $user_group_ids[] = $this->createUserGroup($company_id, 40, 0); $user_group_ids[] = $this->createUserGroup($company_id, 50, $user_group_ids[3]); //Users $user_ids[] = $this->createUser($company_id, 10, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 11, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 12, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 13, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 14, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 15, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 16, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 17, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 18, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 19, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 20, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 21, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 22, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 23, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 24, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 25, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 26, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 27, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 28, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 29, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 30, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 40, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]); $current_user_id = $user_ids[] = $this->createUser($company_id, 100, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]); //Create random users. for ($i = 0; $i <= $this->getMaxRandomUsers(); $i++) { $tmp_user_id = $this->createUser($company_id, 999, 0, $branch_ids[$i % 2], $department_ids[$i % 2], $currency_ids[0], $user_group_ids[$i % 5]); if ($tmp_user_id != FALSE) { $user_ids[] = $tmp_user_id; } } Debug::Arr($user_ids, 'All User IDs:', __FILE__, __LINE__, __METHOD__, 10); $ulf = new UserListFactory(); $ulf->getById($current_user_id); $current_user = $ulf->getCurrent(); unset($current_user_id); //Create policies $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 10); //In $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 20); //Out $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 10); //Bank Time $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 20); //Vacaction $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 30); //Sick $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 10); $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 20, $policy_ids['accrual'][0]); $policy_ids['premium'][] = $this->createPremiumPolicy($company_id, 10); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 10, $policy_ids['accrual'][1]); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 20, $policy_ids['accrual'][0]); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 30, $policy_ids['accrual'][2]); $policy_ids['meal_1'] = $this->createMealPolicy($company_id); $policy_ids['schedule_1'] = $this->createSchedulePolicy($company_id, $policy_ids['meal_1']); $policy_ids['exception_1'] = $this->createExceptionPolicy($company_id); $hierarchy_user_ids = $user_ids; $root_user_id = array_pop($hierarchy_user_ids); unset($hierarchy_user_ids[0], $hierarchy_user_ids[1]); //Create authorization hierarchy $hierarchy_control_id = $this->createAuthorizationHierarchyControl($company_id, $hierarchy_user_ids); if ($root_user_id == FALSE) { Debug::Text('Administrator wasn\'t created! Duplicate username perhaps? Are we appending a random number?', __FILE__, __LINE__, __METHOD__, 10); } //Admin user at the top $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $root_user_id, 1); $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[0], 2); $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[1], 3); unset($hierarchy_user_ids, $root_user_id); //Pay Period Schedule $this->createPayPeriodSchedule($company_id, $user_ids); //Create Policy Group $this->createPolicyGroup($company_id, $policy_ids['meal_1'], $policy_ids['exception_1'], NULL, $policy_ids['overtime'], $policy_ids['premium'], $policy_ids['round'], $user_ids); if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL) { //Task Groups $task_group_ids[] = $this->createTaskGroup($company_id, 10, 0); $task_group_ids[] = $this->createTaskGroup($company_id, 20, $task_group_ids[0]); $task_group_ids[] = $this->createTaskGroup($company_id, 30, $task_group_ids[0]); $task_group_ids[] = $this->createTaskGroup($company_id, 40, 0); $task_group_ids[] = $this->createTaskGroup($company_id, 50, $task_group_ids[3]); $task_group_ids[] = $this->createTaskGroup($company_id, 60, $task_group_ids[3]); //Job Tasks $default_task_id = $this->createTask($company_id, 10, $task_group_ids[2]); $task_ids[] = $this->createTask($company_id, 20, $task_group_ids[1]); $task_ids[] = $this->createTask($company_id, 30, $task_group_ids[1]); $task_ids[] = $this->createTask($company_id, 40, $task_group_ids[2]); $task_ids[] = $this->createTask($company_id, 50, $task_group_ids[4]); $task_ids[] = $this->createTask($company_id, 60, $task_group_ids[4]); $task_ids[] = $this->createTask($company_id, 70, $task_group_ids[5]); //Job Groups $job_group_ids[] = $this->createJobGroup($company_id, 10, 0); $job_group_ids[] = $this->createJobGroup($company_id, 20, $job_group_ids[0]); $job_group_ids[] = $this->createJobGroup($company_id, 30, $job_group_ids[0]); $job_group_ids[] = $this->createJobGroup($company_id, 40, 0); $job_group_ids[] = $this->createJobGroup($company_id, 50, $job_group_ids[3]); $job_group_ids[] = $this->createJobGroup($company_id, 60, $job_group_ids[3]); //Jobs $job_ids[] = $this->createJob($company_id, 10, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 11, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 12, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 13, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 14, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 15, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 16, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 17, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 18, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 19, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 20, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 21, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 22, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 23, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 24, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 25, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); } else { $task_ids[] = 0; $job_ids[] = 0; } //Create Accrual balances foreach ($user_ids as $user_id) { foreach ($policy_ids['accrual'] as $accrual_policy_id) { $this->createAccrualBalance($user_id, $accrual_policy_id); } unset($accrual_policy_id); } //Create recurring schedule templates $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 10, $policy_ids['schedule_1']); //Morning shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 20, $policy_ids['schedule_1']); //Afternoon shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 30, $policy_ids['schedule_1']); //Evening shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 40); //Split Shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 50, $policy_ids['schedule_1']); //Full rotation $recurring_schedule_start_date = TTDate::getBeginWeekEpoch($current_epoch + 86400 * 7.5); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[0], $recurring_schedule_start_date, '', array($user_ids[0], $user_ids[1], $user_ids[2], $user_ids[3], $user_ids[4])); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[1], $recurring_schedule_start_date, '', array($user_ids[5], $user_ids[6], $user_ids[7], $user_ids[8], $user_ids[9])); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[2], $recurring_schedule_start_date, '', array($user_ids[10], $user_ids[11], $user_ids[12], $user_ids[13], $user_ids[14])); //Create schedule for each employee. foreach ($user_ids as $user_id) { //Create schedule starting 6 weeks ago, up to the end of the week. $schedule_options_arr = array('status_id' => 10, 'start_time' => '08:00AM', 'end_time' => '05:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']); //$schedule_date = ($current_epoch-(86400*42)); $schedule_date = $current_epoch - 86400 * 14; $schedule_end_date = TTDate::getEndWeekEpoch($current_epoch); //$schedule_date = ($current_epoch-(86400*14)); //$schedule_end_date = ($current_epoch+(86400*28)); while ($schedule_date <= $schedule_end_date) { //Random departments/branches $schedule_options_arr['branch_id'] = $branch_ids[rand(0, count($branch_ids) - 1)]; $schedule_options_arr['department_id'] = $department_ids[rand(0, count($department_ids) - 1)]; //Skip weekends. if (date('w', $schedule_date) != 0 and date('w', $schedule_date) != 6) { $this->createSchedule($user_id, $schedule_date, $schedule_options_arr); } $schedule_date += 86400; } //break; unset($schedule_options_arr, $schedule_date, $schedule_end_date, $user_id); } //Punch users in/out randomly. foreach ($user_ids as $user_id) { //Pick random jobs/tasks that are used for the entire date range. //So one employee isn't punching into 15 jobs. $user_random_job_ids = array_rand($job_ids, 2); $user_random_task_ids = array_rand($job_ids, 3); //Create punches starting 6 weeks ago, up to the end of the week. //$start_date = $punch_date = ($current_epoch-(86400*42)); $start_date = $punch_date = $current_epoch - 86400 * 14; $end_date = TTDate::getEndWeekEpoch($current_epoch); //$start_date = $punch_date = ($current_epoch-(86400*14)); //$end_date = ($current_epoch+(86400*28)); $i = 0; while ($punch_date <= $end_date) { $date_stamp = TTDate::getDate('DATE', $punch_date); //$punch_full_time_stamp = strtotime($pc_data['date_stamp'].' '.$pc_data['time_stamp']); $exception_cutoff_date = $current_epoch - 86400 * 14; if (date('w', $punch_date) != 0 and date('w', $punch_date) != 6) { if ($punch_date >= $exception_cutoff_date and $i % 4 == 0) { $first_punch_in = rand(7, 8) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'AM'; $last_punch_out = strtotime($date_stamp . ' ' . rand(4, 5) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'PM'); if ($punch_date >= $exception_cutoff_date and rand(0, 20) == 0) { //Create request $this->createRequest(20, $user_id, $date_stamp); } if ($punch_date >= $exception_cutoff_date and rand(0, 16) == 0) { //Create request $this->createRequest(20, $user_id, $date_stamp); } } else { $first_punch_in = '08:00AM'; if ($punch_date >= $exception_cutoff_date and $i % 10 == 0) { //Don't punch out to generate exception. $last_punch_out = NULL; //Forgot to punch out request $this->createRequest(30, $user_id, $date_stamp); } else { $last_punch_out = strtotime($date_stamp . ' 5:00PM'); } } //Weekdays $this->createPunchPair($user_id, strtotime($date_stamp . ' ' . $first_punch_in), strtotime($date_stamp . ' 11:00AM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); $this->createPunchPair($user_id, strtotime($date_stamp . ' 11:00AM'), strtotime($date_stamp . ' 1:00PM'), array('in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); //Calc total time on last punch pair only. $this->createPunchPair($user_id, strtotime($date_stamp . ' 2:00PM'), $last_punch_out, array('in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); } elseif ($punch_date > $exception_cutoff_date and date('w', $punch_date) == 6 and $i % 10 == 0) { //Sat. $this->createPunchPair($user_id, strtotime($date_stamp . ' 10:00AM'), strtotime($date_stamp . ' 2:30PM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); } //Recalculate entire day. Performance optimization. //UserDateTotalFactory::reCalculateRange( $user_id, $start_date, $end_date ); $punch_date += 86400; $i++; } unset($punch_options_arr, $punch_date, $user_id); } //Generate pay stubs for each pay period $pplf = new PayPeriodListFactory(); $pplf->getByCompanyId($company_id); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { foreach ($user_ids as $user_id) { $cps = new CalculatePayStub(); $cps->setUser($user_id); $cps->setPayPeriod($pp_obj->getId()); $cps->calculate(); } } } unset($pplf, $pp_obj, $user_id); } //$cf->FailTransaction(); $cf->CommitTransaction(); return FALSE; }
/** * @param array $data user review control IDs * @return array */ function copyUserReviewControl($data) { if (is_numeric($data)) { $data = array($data); } if (!is_array($data)) { return $this->returnHandler(FALSE); } Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); $src_rows = $this->stripReturnHandler($this->getUserReviewControl(array('filter_data' => array('id' => $data)), TRUE)); if (is_array($src_rows) and count($src_rows) > 0) { Debug::Arr($src_rows, 'SRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($src_rows as $key => $row) { unset($src_rows[$key]['id']); //Clear fields that can't be copied } //Debug::Arr($src_rows, 'bSRC Rows: ', __FILE__, __LINE__, __METHOD__, 10); return $this->setUserReviewControl($src_rows); //Save copied rows } return $this->returnHandler(FALSE); }
$ugdlf = TTnew('UserGenericDataListFactory'); $ugdf = TTnew('UserGenericDataFactory'); $action = Misc::findSubmitButton(); Debug::Text('Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10); switch ($action) { case 'display_form': case 'print_form': case 'display_report': //Debug::setVerbosity(11); if ($action == 'print_form') { $show_background = FALSE; } else { $show_background = TRUE; } Debug::Text('Submit!: ' . $action, __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($filter_data, 'aFilter Data', __FILE__, __LINE__, __METHOD__, 10); //Save report setup data $ugdlf->getByCompanyIdAndScriptAndDefault($current_company->getId(), $_SERVER['SCRIPT_NAME']); if ($ugdlf->getRecordCount() > 0) { $ugdf->setID($ugdlf->getCurrent()->getID()); } $ugdf->setCompany($current_company->getId()); $ugdf->setScript($_SERVER['SCRIPT_NAME']); $ugdf->setName($title); $ugdf->setData($setup_data); $ugdf->setDefault(TRUE); if ($ugdf->isValid()) { $ugdf->Save(); } $ulf = TTnew('UserListFactory'); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
function _getFactoryOptions($name, $parent = NULL) { $retval = NULL; switch ($name) { case 'columns': global $current_company; $uf = TTNew('UserFactory'); $retval = Misc::trimSortPrefix($uf->getOptions('columns')); $retval['-1025-password'] = TTi18n::getText('Password'); $retval['-1026-phone_password'] = TTi18n::getText('Quick Punch Password'); $retval['-1099-group'] = isset($retval['-1099-user_group']) ? $retval['-1099-user_group'] : NULL; unset($retval['-1099-user_group']); ksort($retval); //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) { unset($retval['-1104-default_job'], $retval['-1105-default_job_item']); } if (is_object($current_company)) { //Get custom fields for import data. $oflf = TTnew('OtherFieldListFactory'); $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($current_company->getID(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = array_merge((array) $retval, (array) $other_field_names); } } Debug::Arr($retval, 'ImportUserColumns: ', __FILE__, __LINE__, __METHOD__, 10); break; case 'column_aliases': //Used for converting column names after they have been parsed. $retval = array('status' => 'status_id', 'default_branch' => 'default_branch_id', 'default_department' => 'default_department_id', 'default_job' => 'default_job_id', 'default_job_item' => 'default_job_item_id', 'title' => 'title_id', 'user_group' => 'group_id', 'group' => 'group_id', 'sex' => 'sex_id', 'permission_control' => 'permission_control_id', 'pay_period_schedule' => 'pay_period_schedule_id', 'policy_group' => 'policy_group_id', 'hierarchy_control_display' => 'hierarchy_control'); break; case 'import_options': $retval = array('-1010-fuzzy_match' => TTi18n::getText('Enable smart matching.'), '-1015-update' => TTi18n::getText('Update existing records based on UserName, Employee Number, or SIN/SSN.'), '-1040-create_group' => TTi18n::getText('Create groups that don\'t already exist.'), '-1050-create_title' => TTi18n::getText('Create titles that don\'t already exist.')); break; case 'parse_hint': $upf = TTnew('UserPreferenceFactory'); $retval = array('default_branch' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'default_department' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'default_job' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'default_job_item' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'first_name' => array('-1010-first_name' => TTi18n::gettext('First Name'), '-1020-first_last_name' => TTi18n::gettext('FirstName LastName'), '-1030-last_first_name' => TTi18n::gettext('LastName, FirstName'), '-1040-last_first_middle_name' => TTi18n::gettext('LastName, FirstName MiddleInitial')), 'last_name' => array('-1010-last_name' => TTi18n::gettext('Last Name'), '-1020-first_last_name' => TTi18n::gettext('FirstName LastName'), '-1030-last_first_name' => TTi18n::gettext('LastName, FirstName'), '-1040-last_first_middle_name' => TTi18n::gettext('LastName, FirstName MiddleInitial')), 'middle_name' => array('-1010-middle_name' => TTi18n::gettext('Middle Name'), '-1040-last_first_middle_name' => TTi18n::gettext('LastName, FirstName MiddleInitial')), 'hire_date' => $upf->getOptions('date_format'), 'termination_date' => $upf->getOptions('date_format'), 'birth_date' => $upf->getOptions('date_format')); break; } return $retval; }
function getArray() { $array = array('gross_pay' => $this->getGrossPayPeriodIncome(), 'federal_tax' => $this->getFederalPayPeriodDeductions(), 'provincial_tax' => $this->getProvincialPayPeriodDeductions(), 'total_tax' => $this->getPayPeriodTaxDeductions(), 'employee_cpp' => $this->getEmployeeCPP(), 'employer_cpp' => $this->getEmployerCPP(), 'employee_ei' => $this->getEmployeeEI(), 'employer_ei' => $this->getEmployerEI(), 'employer_wcb' => $this->getEmployerWCB(), 'federal_additional_deduction' => $this->getFederalAdditionalDeduction()); Debug::Arr($array, 'Deductions Array:', __FILE__, __LINE__, __METHOD__, 10); return $array; }
function writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day = 0, $bottom_border = FALSE) { $week_of_year = TTDate::getWeek(strtotime($week_date_stamps[0]), $start_week_day); //Debug::Text('Max Week Shifts: '. (int)$max_week_data[$week_of_year]['shift'], __FILE__, __LINE__, __METHOD__,10); //Debug::Text('Max Week Branches: '. count($max_week_data[$week_of_year]['branch']), __FILE__, __LINE__, __METHOD__,10); //Debug::Text('Max Week Departments: '. count($max_week_data[$week_of_year]['department']), __FILE__, __LINE__, __METHOD__,10); Debug::Text('Week Of Year: ' . $week_of_year, __FILE__, __LINE__, __METHOD__, 10); Debug::Arr($max_week_data, 'max_week_data: ', __FILE__, __LINE__, __METHOD__, 10); $week_data_array = NULL; if (!isset($max_week_data[$week_of_year]['labels'])) { $max_week_data[$week_of_year]['labels'] = 0; } if ($group_schedule == TRUE) { $min_rows_multiplier = 2; } else { $min_rows_multiplier = 1; } if (isset($max_week_data[$week_of_year]['shift'])) { $min_rows_per_day = $max_week_data[$week_of_year]['shift'] * $min_rows_multiplier + $max_week_data[$week_of_year]['labels']; Debug::Text('Shift Total: ' . $max_week_data[$week_of_year]['shift'], __FILE__, __LINE__, __METHOD__, 10); } else { $min_rows_per_day = $min_rows_multiplier + $max_week_data[$week_of_year]['labels']; } Debug::Text('aMin Rows Per Day: ' . $min_rows_per_day . ' Labels: ' . $max_week_data[$week_of_year]['labels'], __FILE__, __LINE__, __METHOD__, 10); //print_r($this->schedule_shifts); //Prepare data so we can write it out line by line, left to right. $shift_counter = 0; foreach ($week_date_stamps as $week_date_stamp) { Debug::Text('Week Date Stamp: (' . $week_date_stamp . ')' . TTDate::getDate('DATE+TIME', strtotime($week_date_stamp)), __FILE__, __LINE__, __METHOD__, 10); $rows_per_day = 0; if (isset($this->schedule_shifts[$week_date_stamp])) { foreach ($this->schedule_shifts[$week_date_stamp] as $branch => $department_schedule_shifts) { if ($branch != '--') { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'branch', 'date_stamp' => $week_date_stamp, 'label' => $branch); $rows_per_day++; } foreach ($department_schedule_shifts as $department => $tmp_schedule_shifts) { if ($department != '--') { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'department', 'label' => $department); $rows_per_day++; } foreach ($tmp_schedule_shifts as $schedule_shift) { if ($group_schedule == TRUE) { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'user_name', 'label' => $schedule_shift['user_full_name'], 'shift' => $shift_counter); if ($schedule_shift['status_id'] == 10) { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'shift', 'label' => TTDate::getDate('TIME', $schedule_shift['start_time']) . ' - ' . TTDate::getDate('TIME', $schedule_shift['end_time']), 'shift' => $shift_counter); } else { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'absence', 'label' => $schedule_shift['absence_policy'], 'shift' => $shift_counter); } $rows_per_day += 2; } else { if ($schedule_shift['status_id'] == 10) { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'shift', 'label' => TTDate::getDate('TIME', $schedule_shift['start_time']) . ' - ' . TTDate::getDate('TIME', $schedule_shift['end_time']), 'shift' => $shift_counter); } else { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'absence', 'label' => $schedule_shift['absence_policy'], 'shift' => $shift_counter); } $rows_per_day++; } $shift_counter++; } } } } if ($rows_per_day < $min_rows_per_day) { for ($z = $rows_per_day; $z < $min_rows_per_day; $z++) { $tmp_week_data_array[$week_date_stamp][] = array('type' => 'blank', 'label' => NULL); } } } //print_r($tmp_week_data_array); for ($x = 0; $x < $min_rows_per_day; $x++) { foreach ($week_date_stamps as $week_date_stamp) { if (isset($tmp_week_data_array[$week_date_stamp][0])) { $week_data_array[] = $tmp_week_data_array[$week_date_stamp][0]; array_shift($tmp_week_data_array[$week_date_stamp]); } } } unset($tmp_week_data_array); //print_r($week_data_array); //Render PDF here $border = 'LR'; $i = 0; $total_cells = count($week_data_array); foreach ($week_data_array as $key => $data) { if ($i % 7 == 0) { $pdf->Ln(); } $pdf->setTextColor(0, 0, 0); //Black switch ($data['type']) { case 'branch': $pdf->setFillColor(200, 200, 200); $pdf->SetFont('freesans', 'B', 8); break; case 'department': $pdf->setFillColor(220, 220, 220); $pdf->SetFont('freesans', 'B', 8); break; case 'user_name': if ($data['shift'] % 2 == 0) { $pdf->setFillColor(240, 240, 240); } else { $pdf->setFillColor(255, 255, 255); } $pdf->SetFont('freesans', 'B', 8); break; case 'shift': if ($data['shift'] % 2 == 0) { $pdf->setFillColor(240, 240, 240); } else { $pdf->setFillColor(255, 255, 255); } $pdf->SetFont('freesans', '', 8); break; case 'absence': $pdf->setTextColor(255, 0, 0); if ($data['shift'] % 2 == 0) { $pdf->setFillColor(240, 240, 240); } else { $pdf->setFillColor(255, 255, 255); } $pdf->SetFont('freesans', 'I', 8); break; case 'blank': $pdf->setFillColor(255, 255, 255); $pdf->SetFont('freesans', '', 8); break; } if ($bottom_border == TRUE and $i >= $total_cells - 7) { $border = 'LRB'; } $pdf->Cell($cell_width, 15, $data['label'], $border, 0, 'C', 1); $pdf->setTextColor(0, 0, 0); //Black $i++; } $pdf->Ln(); return TRUE; }
function setObjectType($ids) { if (is_array($ids) and count($ids) > 0) { $tmp_ids = array(); Debug::Arr($ids, 'IDs: ', __FILE__, __LINE__, __METHOD__, 10); if (!$this->isNew()) { //If needed, delete mappings first. $lf_a = TTnew('HierarchyObjectTypeListFactory'); $lf_a->getByHierarchyControlId($this->getId()); Debug::text('Existing Object Type Rows: ' . $lf_a->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); foreach ($lf_a as $obj) { //$id = $obj->getId(); $id = $obj->getObjectType(); //Need to use object_types rather than row IDs. Debug::text('Hierarchy Object Type ID: ' . $obj->getId() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($id, $ids)) { Debug::text('Deleting: Object Type: ' . $id . ' ID: ' . $obj->getID(), __FILE__, __LINE__, __METHOD__, 10); $obj->Delete(); } else { //Save ID's that need to be updated. Debug::text('NOT Deleting: Object Type: ' . $id . ' ID: ' . $obj->getID(), __FILE__, __LINE__, __METHOD__, 10); $tmp_ids[] = $id; } } unset($id, $obj); } foreach ($ids as $id) { if (isset($ids) and !in_array($id, $tmp_ids)) { $f = TTnew('HierarchyObjectTypeFactory'); $f->setHierarchyControl($this->getId()); $f->setObjectType($id); if ($this->Validator->isTrue('object_type', $f->Validator->isValid(), TTi18n::gettext('Object type is already assigned to another hierarchy'))) { $f->save(); } } } return TRUE; } $this->Validator->isTrue('object_type', FALSE, TTi18n::gettext('At least one object must be selected')); return FALSE; }
function getInsurableEarningsByPayPeriod() { if ($this->pay_period_earnings !== NULL) { return $this->pay_period_earnings; } $setup_data = $this->getSetupData(); $insurable_earnings_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableEarningsReportPayPeriods()); $pself = TTnew('PayStubEntryListFactory'); $pself->getPayPeriodReportByUserIdAndEntryNameIdAndStartDateAndEndDate($this->getUser(), $setup_data['insurable_earnings_psea_ids'], $insurable_earnings_start_date, $this->getLastDate(), 0, NULL, array('x.start_date' => 'desc')); if ($pself->getRecordCount() > 0) { foreach ($pself as $pse_obj) { $retarr[$pse_obj->getColumn('pay_period_id')] = array('amount' => $pse_obj->getColumn('amount'), 'units' => $pse_obj->getColumn('units')); } } if (isset($retarr)) { Debug::Arr($retarr, 'Pay Period Earnings: ', __FILE__, __LINE__, __METHOD__, 10); $this->pay_period_earnings = $retarr; return $this->pay_period_earnings; } return FALSE; }
function isUniqueName($name) { $ph = array('company_id' => $this->getCompany(), 'name' => strtolower($name)); $query = 'select id from ' . $this->getTable() . ' where company_id = ? AND lower(name) = ? AND deleted=0'; $id = $this->db->GetOne($query, $ph); Debug::Arr($id, 'Unique: ' . $name, __FILE__, __LINE__, __METHOD__, 10); if ($id === FALSE) { return TRUE; } else { if ($id == $this->getId()) { return TRUE; } } return FALSE; }
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; }
} } $lines_arr[$quarter_id]['p1_3'] = $lines_arr[$quarter_id]['p1_1'] - $lines_arr[$quarter_id]['p1_2'] - $lines_arr[$quarter_id]['p3_under_cutoff']; $lines_arr[$quarter_id]['p1_4'] = $lines_arr[$quarter_id]['p1_2'] + $lines_arr[$quarter_id]['p1_3']; $lines_arr[$quarter_id]['p1_5'] = $lines_arr[$quarter_id]['p1_1'] - $lines_arr[$quarter_id]['p1_4']; $lines_arr[$quarter_id]['p1_6'] = bcmul($lines_arr[$quarter_id]['p1_5'], 0.008); } unset($user_id); //var_dump($user_ps_entries); } unset($pay_period_ids, $ps_entries); } //Calc Part 1, Line 3 here. if (isset($lines_arr)) { $lines_arr['total'] = Misc::ArrayAssocSum($lines_arr, NULL, 6); Debug::Arr($lines_arr, 'Lines Array: ', __FILE__, __LINE__, __METHOD__, 10); //Line 8 $p1_line8 = $lines_arr['total']['p1_6'] - 0; } $border = 0; $pdf = new fpdi(); //Import original Gov't supplied PDF. if ($show_background == TRUE) { $pagecount = $pdf->setSourceFile(Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'us' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 'f940ez.pdf'); $tplidx = $pdf->ImportPage(1); } $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(FALSE); $pdf->SetFont('freeserif', '', 10); $pdf->AddPage(); if (isset($tplidx)) {
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; }
function getByUserIdAndObjectTypeIDAndLevelAndHierarchyControlIDs($user_id, $object_type_id, $level = 1, $hierarchy_control_ids, $recursive = TRUE) { if ($user_id == '') { return FALSE; } if (!is_numeric($level)) { return FALSE; } $min_level = $level - 1; if ($min_level <= 0) { $min_level = 0; } //This should have two modes, one where it returns just the immediate child level, and one that returns all children "recursively". if ($recursive == TRUE) { $max_level = 99; } else { $max_level = $level + 1; } Debug::Text(' User ID: ' . $user_id . ' Object Type ID: ' . $object_type_id . ' Level: ' . $level . ' Min Level: ' . $min_level . ' Max Level: ' . $max_level, __FILE__, __LINE__, __METHOD__, 10); $retarr = array('current_level' => array(), 'parent_level' => array(), 'child_level' => array()); $hcf = new HierarchyControlFactory(); $hlf = new HierarchyLevelFactory(); $huf = new HierarchyUserFactory(); $hotf = new HierarchyObjectTypeFactory(); $ph = array(); //UNION two queries together, the first query gets all superiors, one level above, and all levels below. //The 2nd query gets all subordinates. $query = ' select * from ( select x.hierarchy_control_id, x.user_id, x.level, 0 as is_subordinate from ' . $hlf->getTable() . ' as x LEFT JOIN ' . $hcf->getTable() . ' as y ON x.hierarchy_control_id = y.id LEFT JOIN ' . $hotf->getTable() . ' as y2 ON x.hierarchy_control_id = y2.hierarchy_control_id LEFT JOIN ' . $hlf->getTable() . ' as z ON x.hierarchy_control_id = z.hierarchy_control_id AND z.user_id = ' . (int) $user_id . ' where y2.object_type_id in (' . $this->getListSQL($object_type_id, $ph) . ') AND x.level >= z.level-1 AND ( x.deleted = 0 AND y.deleted = 0 AND z.deleted = 0 ) UNION ALL select n.hierarchy_control_id, n.user_id, ( select max(level)+1 from ' . $hlf->getTable() . ' as z where z.hierarchy_control_id = n.hierarchy_control_id AND z.deleted = 0 ) as level, 1 as is_subordinate from ' . $huf->getTable() . ' as n LEFT JOIN ' . $hcf->getTable() . ' as o ON n.hierarchy_control_id = o.id LEFT JOIN ' . $hotf->getTable() . ' as p ON n.hierarchy_control_id = p.hierarchy_control_id LEFT JOIN ' . $hlf->getTable() . ' as z ON n.hierarchy_control_id = z.hierarchy_control_id AND z.user_id = ' . (int) $user_id . ' where p.object_type_id in (' . $this->getListSQL($object_type_id, $ph) . ') AND ( o.deleted = 0 AND z.deleted = 0 ) ) as tmp WHERE hierarchy_control_id in (' . $this->getListSQL($hierarchy_control_ids, $ph) . ') AND ( level >= ' . (int) $min_level . ' AND level <= ' . (int) $max_level . ' ) ORDER BY level ASC, user_id ASC '; //Debug::Text(' Query: '. $query, __FILE__, __LINE__, __METHOD__,10); $rs = $this->db->Execute($query, $ph); //Debug::Text(' Rows: '. $rs->RecordCount(), __FILE__, __LINE__, __METHOD__,10); if ($rs->RecordCount() > 0) { $current_level = $level; $i = 0; foreach ($rs as $row) { Debug::Text(' User ID: ' . $row['user_id'] . ' Level: ' . $row['level'] . ' Sub: ' . $row['is_subordinate'] . ' Current Level: ' . $current_level, __FILE__, __LINE__, __METHOD__, 10); if ($row['level'] == $current_level and $row['is_subordinate'] == 0) { $retarr['current_level'][] = $row['user_id']; } elseif ($row['level'] < $current_level and $row['is_subordinate'] == 0) { $retarr['parent_level'][] = $row['user_id']; } elseif ($row['level'] > $current_level and $row['is_subordinate'] == 1) { //Only ever show suborindates at child levels, this fixes the bug where the currently logged in user would see their own requests //in the authorization list. $retarr['child_level'][] = $row['user_id']; } else { //Debug::Text(' Skipping row...', __FILE__, __LINE__, __METHOD__,10); } $i++; } $retarr['current_level'] = array_unique($retarr['current_level']); $retarr['parent_level'] = array_unique($retarr['parent_level']); $retarr['child_level'] = array_unique($retarr['child_level']); Debug::Arr($retarr, ' aChildren of User: '******' At Level: ' . $level, __FILE__, __LINE__, __METHOD__, 10); return $retarr; } return FALSE; }