function setCompany($id) { $id = trim($id); $clf = new CompanyListFactory(); if ($this->Validator->isResultSetWithRows('company', $clf->getByID($id), TTi18n::gettext('Company is invalid'))) { $this->data['company_id'] = $id; return TRUE; } return FALSE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $clf = new CompanyListFactory(); $clf->StartTransaction(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() == 10) { $ulf = new 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 sendEmail($to, $headers, $body) { global $config_vars; if (!isset($config_vars['other']['primary_company_id'])) { $config_vars['other']['primary_company_id'] = 1; } $clf = new CompanyListFactory(); $clf->getById($config_vars['other']['primary_company_id']); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { $company_data = array('system_version' => APPLICATION_VERSION, 'registration_key' => $this->getLocalRegistrationKey(), 'product_edition_id' => $c_obj->getProductEdition(), 'product_edition_available' => getTTProductEdition(), 'name' => $c_obj->getName(), 'short_name' => $c_obj->getShortName(), 'work_phone' => $c_obj->getWorkPhone(), 'city' => $c_obj->getCity(), 'country' => $c_obj->getCountry(), 'province' => $c_obj->getProvince(), 'postal_code' => $c_obj->getPostalCode()); } } if (isset($company_data) and $to != '' and $body != '') { return $this->getSoapObject()->sendEmail($to, $headers, $body, $company_data); } return FALSE; }
$sf = new StationFactory(); $sf->setCompany($current_company->getId()); $sf->setStatus('ENABLED'); $sf->setType('PC'); $sf->setSource($_SERVER['REMOTE_ADDR']); $sf->setStation(); $sf->setDescription(substr($_SERVER['HTTP_USER_AGENT'], 0, 250)); if ($sf->Save(FALSE)) { $sf->setCookie(); } } Redirect::Page(URLBuilder::getURL(NULL, 'index.php')); } else { $error_message = TTi18n::gettext('User Name or Password is incorrect'); //Get company status from user_name, so we can display messages for ONHOLD/Cancelled accounts. $clf = new CompanyListFactory(); $clf->getByUserName($user_name); if ($clf->getRecordCount() > 0) { $c_obj = $clf->getCurrent(); if ($c_obj->getStatus() == 20) { $error_message = TTi18n::gettext('Sorry, your company\'s account has been placed ON HOLD, please contact customer support immediately'); } elseif ($c_obj->getStatus() == 30) { $error_message = TTi18n::gettext('Sorry, your company\'s account has been CANCELLED, please contact customer support if you believe this is an error'); } } $validator->isTrue('user_name', FALSE, $error_message); } break; default: break; }
function getROE($rlf = NULL, $show_background = TRUE) { if (!is_object($rlf) and $this->getId() != '') { $rlf = new ROEListFactory(); $rlf->getById($this->getId()); } if (get_class($rlf) !== 'ROEListFactory') { return FALSE; } $border = 0; if ($rlf->getRecordCount() > 0) { $ppsf = new PayPeriodScheduleListFactory(); $pay_period_type_options = $ppsf->getOptions('type'); $pdf = new TTPDF(); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(FALSE); foreach ($rlf as $r_obj) { $pdf->SetFont('freesans', '', 12); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($r_obj->getUser())->getCurrent(); $ulf = new UserListFactory(); $created_user_obj = $ulf->getById($r_obj->getCreatedBy())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); $pdf->AddPage(); if ($show_background == TRUE) { $pdf->Image(Environment::getImagesPath() . 'roe-template.jpg', 0, 0, 210, 300); } //Serial $pdf->setXY(10, 17); $pdf->Cell(55, 10, $r_obj->getSerial(), $border, 0, 'L'); //Employer Info $pdf->setXY(10, 30); $pdf->Cell(120, 10, $company_obj->getName(), $border, 0, 'L'); $pdf->setXY(10, 40); $pdf->Cell(120, 10, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'L'); $pdf->setXY(10, 50); $pdf->Cell(90, 10, $company_obj->getCity() . ', ' . $company_obj->getProvince(), $border, 0, 'L'); $postal_code_a = substr($company_obj->getPostalCode(), 0, 3); $postal_code_b = substr($company_obj->getPostalCode(), 3, 6); $pdf->setXY(110, 50); $pdf->Cell(10, 10, $postal_code_a, $border, 0, 'L'); $pdf->setXY(122, 50); $pdf->Cell(10, 10, $postal_code_b, $border, 0, 'L'); //Business Number $pdf->setXY(138, 28); $pdf->Cell(120, 10, $company_obj->getBusinessNumber(), $border, 0, 'L'); //Pay Period Type $pdf->setXY(138, 40); $pdf->Cell(50, 10, $pay_period_type_options[$r_obj->getPayPeriodType()], $border, 0, 'L'); //SIN $pdf->setXY(138, 50); $pdf->Cell(50, 10, $user_obj->getSIN(), $border, 0, 'L'); //Employee info $pdf->SetFontSize(10); $pdf->setXY(10, 75); $pdf->Cell(90, 5, $user_obj->getFullName(), $border, 0, 'L'); $pdf->setXY(10, 80); $pdf->Cell(90, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L'); $pdf->setXY(10, 85); $pdf->Cell(90, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L'); $pdf->SetFontSize(12); //Employee Title if (is_object($user_obj->getTitleObject())) { $title = $user_obj->getTitleObject()->getName(); } else { $title = NULL; } $pdf->setXY(10, 100); $pdf->Cell(90, 10, $title, $border, 0, 'L'); //First Day Worked $pdf->SetFontSize(10); $first_date = getdate($r_obj->getFirstDate()); $pdf->setXY(175, 64); $pdf->Cell(8, 10, $first_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 64); $pdf->Cell(8, 10, $first_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 64); $pdf->Cell(10, 10, $first_date['year'], $border, 0, 'C'); //Last day paid $last_date = getdate($r_obj->getLastDate()); $pdf->setXY(175, 75); $pdf->Cell(8, 10, $last_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 75); $pdf->Cell(8, 10, $last_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 75); $pdf->Cell(10, 10, $last_date['year'], $border, 0, 'C'); //Pay Period End Date $pay_period_end_date = getdate($r_obj->getPayPeriodEndDate()); $pdf->setXY(175, 86); $pdf->Cell(8, 10, $pay_period_end_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 86); $pdf->Cell(8, 10, $pay_period_end_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 86); $pdf->Cell(10, 10, $pay_period_end_date['year'], $border, 0, 'C'); //Insurable Hours $pdf->SetFontSize(10); $pdf->setXY(75, 113); $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableHours()), $border, 0, 'R'); $pdf->setXY(101, 113); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableHours(), FALSE)), $border, 0, 'L'); //Enter Code $pdf->setXY(185, 113); $pdf->Cell(10, 10, $r_obj->getCode(), $border, 0, 'C'); //Further Information Contact Name $pdf->setXY(130, 126); $pdf->Cell(75, 5, $created_user_obj->getFullName(), $border, 0, 'R'); $pdf->setXY(130, 132); $pdf->Cell(75, 10, $created_user_obj->getWorkPhone(), $border, 0, 'R'); //Insurable Earnings $pdf->setXY(75, 131); $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableEarnings()), $border, 0, 'R'); $pdf->setXY(101, 131); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableEarnings(), FALSE)), $border, 0, 'L'); //Check to see if a pay period didn't have earnings. if ($r_obj->isPayPeriodWithNoEarnings() == TRUE) { $pay_period_earnings = $r_obj->getInsurableEarningsByPayPeriod(); if (is_array($pay_period_earnings)) { //Add additional entries for testing alignment purposes. /* for( $y=0; $y < 14; $y++ ) { $pay_period_earnings[] = array('amount' => rand(1,10) ); } */ $top_left_x = $x = Misc::AdjustXY(30, 0); $top_left_y = $y = Misc::AdjustXY(157, 0); $col = 1; $i = 1; foreach ($pay_period_earnings as $pay_period_earning) { Debug::Text('I: ' . $i . ' X: ' . $x . ' Y: ' . $y . ' Col: ' . $col . ' Amount: ' . (double) $pay_period_earning['amount'], __FILE__, __LINE__, __METHOD__, 10); $pdf->setXY($x, $y); $pdf->Cell(6, 6, Misc::MoneyFormat((double) $pay_period_earning['amount'], FALSE), $border, 0, 'R'); if ($i > 0 and $i % 3 == 0) { $x = $top_left_x; $y += 7; } else { $x += 35; } $i++; } } } //Box 17A, Vacation pay in last pay period. $vacation_pay = $r_obj->getLastPayPeriodVacationEarnings(); if ($vacation_pay > 0) { $pdf->setXY(132, 155); $pdf->Cell(10, 10, Misc::getBeforeDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'R'); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'L'); } //Comments $pdf->setXY(115, 212); $pdf->MultiCell(85, 5, $r_obj->getComments(), $border, 'L'); //English $pdf->setXY(8.5, 256.5); $pdf->Cell(10, 10, 'X', $border, 0, 'L'); //ROE creator phone number $pdf->setXY(75, 258); $pdf->Cell(25, 10, $created_user_obj->getWorkPhone(), $border, 0, 'L'); //ROE create name. $pdf->SetFontSize(12); $pdf->setXY(87, 273); $pdf->Cell(75, 10, $created_user_obj->getFullName(), $border, 0, 'C'); //Create Date $created_date = getdate($r_obj->getCreatedDate()); $pdf->SetFontSize(10); $pdf->setXY(175, 273); $pdf->Cell(8, 10, $created_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 273); $pdf->Cell(8, 10, $created_date['mon'], $border, 0, 'C'); $pdf->setXY(195, 273); $pdf->Cell(10, 10, $created_date['year'], $border, 0, 'C'); } $output = $pdf->Output('', 'S'); } if (isset($output)) { return $output; } return FALSE; }
/* * $Revision: 8904 $ * $Id: calcExceptions.php 8904 2013-01-20 17:21:15Z ipso $ * $Date: 2013-01-20 09:21:15 -0800 (Sun, 20 Jan 2013) $ */ /* * Calculate Exceptions for the previous day. This helps especially for * the "Unscheuled Absence" exception. * * Run this once a day. AFTER AddUserDate */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; //Debug::setVerbosity(5); $execution_time = time(); $clf = new CompanyListFactory(); $clf->getAll(); $x = 0; if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { $company_start_time = microtime(TRUE); Debug::text('Company: ' . $c_obj->getName() . '(' . $c_obj->getId() . ')', __FILE__, __LINE__, __METHOD__, 5); //Recalculate at least the last two days. $start_date = TTDate::getMiddleDayEpoch($execution_time) - 86400 * 2; $end_date = TTDate::getMiddleDayEpoch(time()) - 86400; //Get the last time cron ran this script. $cjlf = new CronJobListFactory(); $cjlf->getByName('calcExceptions'); if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cj_obj) {
if ($cf->isValid()) { $cf->Save(); //$cf->FailTransaction(); $cf->CommitTransaction(); if ($permission->Check('company', 'edit')) { Redirect::Page(URLBuilder::getURL(NULL, 'CompanyList.php')); } else { Redirect::Page(URLBuilder::getURL(NULL, '../index.php')); } break; } $cf->FailTransaction(); default: if (isset($id)) { BreadCrumb::setCrumb($title); $clf = new CompanyListFactory(); if ($permission->Check('company', 'edit')) { $clf->GetByID($id); } else { $id = $current_company->getId(); $clf->GetByID($id); } foreach ($clf as $company) { //Debug::Arr($company,'Company', __FILE__, __LINE__, __METHOD__,10); $company_data = array('id' => $company->getId(), 'parent' => $company->getParent(), 'status' => $company->getStatus(), 'product_edition' => $company->getProductEdition(), 'name' => $company->getName(), 'short_name' => $company->getShortName(), 'business_number' => $company->getBusinessNumber(), 'originator_id' => $company->getOriginatorID(), 'data_center_id' => $company->getDataCenterID(), 'address1' => $company->getAddress1(), 'address2' => $company->getAddress2(), 'city' => $company->getCity(), 'province' => $company->getProvince(), 'country' => $company->getCountry(), 'postal_code' => $company->getPostalCode(), 'work_phone' => $company->getWorkPhone(), 'fax_phone' => $company->getFaxPhone(), 'admin_contact' => $company->getAdminContact(), 'billing_contact' => $company->getBillingContact(), 'support_contact' => $company->getSupportContact(), 'logo_file_name' => $company->getLogoFileName(NULL, FALSE), 'enable_second_last_name' => $company->getEnableSecondLastName(), 'created_date' => $company->getCreatedDate(), 'created_by' => $company->getCreatedBy(), 'updated_date' => $company->getUpdatedDate(), 'updated_by' => $company->getUpdatedBy(), 'deleted_date' => $company->getDeletedDate(), 'deleted_by' => $company->getDeletedBy()); } } //Select box options; $company_data['status_options'] = $cf->getOptions('status'); $company_data['country_options'] = $cf->getOptions('country'); //Company list.
/** * Get about data . * */ function getAboutData($ytd = 0, $all_companies = FALSE) { global $config_vars; $clf = new CompanyListFactory(); $sslf = new SystemSettingListFactory(); $system_settings = $sslf->getAllArray(); $clf->getByID(PRIMARY_COMPANY_ID); if ($clf->getRecordCount() == 1) { $primary_company = $clf->getCurrent(); } $current_user = $this->getCurrentUserObject(); if (isset($primary_company) and PRIMARY_COMPANY_ID == $current_user->getCompany()) { $current_company = $primary_company; } else { $current_company = $clf->getByID($current_user->getCompany())->getCurrent(); } //$current_user_prefs = $current_user->getUserPreferenceObject(); $data = $system_settings; if (isset($data['new_version']) and $data['new_version'] == TRUE) { $data['new_version'] = TRUE; } else { $data['new_version'] = FALSE; } $data['product_edition'] = Option::getByKey(DEPLOYMENT_ON_DEMAND == TRUE ? $current_company->getProductEdition() : getTTProductEdition(), $current_company->getOptions('product_edition')); $data['application_name'] = APPLICATION_NAME; $data['organization_url'] = ORGANIZATION_URL; //Get Employee counts for this month, and last month $month_of_year_arr = TTDate::getMonthOfYearArray(); //This month if (isset($ytd) and $ytd == 1) { $begin_month_epoch = strtotime('-2 years'); } else { $begin_month_epoch = TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch(time()) - 86400); } $cuclf = TTnew('CompanyUserCountListFactory'); if (isset($config_vars['other']['primary_company_id']) and $current_company->getId() == $config_vars['other']['primary_company_id'] and $all_companies == TRUE) { $cuclf->getTotalMonthlyMinAvgMaxByCompanyStatusAndStartDateAndEndDate(10, $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc')); } else { $cuclf->getMonthlyMinAvgMaxByCompanyIdAndStartDateAndEndDate($current_company->getId(), $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc')); } Debug::Text('Company User Count Rows: ' . $cuclf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($cuclf->getRecordCount() > 0) { foreach ($cuclf as $cuc_obj) { $data['user_counts'][] = array('label' => $month_of_year_arr[TTDate::getMonth(TTDate::strtotime($cuc_obj->getColumn('date_stamp')))] . ' ' . TTDate::getYear(TTDate::strtotime($cuc_obj->getColumn('date_stamp'))), 'max_active_users' => $cuc_obj->getColumn('max_active_users'), 'max_inactive_users' => $cuc_obj->getColumn('max_inactive_users'), 'max_deleted_users' => $cuc_obj->getColumn('max_deleted_users')); } } if (isset($data['user_counts']) == FALSE) { $data['user_counts'] = array(); } $cjlf = TTnew('CronJobListFactory'); $cjlf->getMostRecentlyRun(); if ($cjlf->getRecordCount() > 0) { $cj_obj = $cjlf->getCurrent(); $data['cron'] = array('last_run_date' => $cj_obj->getLastRunDate() == FALSE ? TTi18n::getText('Never') : TTDate::getDate('DATE+TIME', $cj_obj->getLastRunDate())); } $data['show_license_data'] = FALSE; if ((DEPLOYMENT_ON_DEMAND == FALSE and $current_company->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $current_company->getId() == $config_vars['other']['primary_company_id']) and getTTProductEdition() > 10) { if (!isset($system_settings['license'])) { $system_settings['license'] = NULL; } $data['show_license_data'] = TRUE; //Set this so the license upload area at least shows up regardles of edition. $data['license_data'] = array(); $license = new TTLicense(); $retval = $license->validateLicense($system_settings['license']); if ($retval == TRUE) { $data['license_data'] = array('organization_name' => $license->getOrganizationName(), 'major_version' => $license->getMajorVersion(), 'minor_version' => $license->getMinorVersion(), 'product_name' => $license->getProductName(), 'active_employee_licenses' => $license->getActiveEmployeeLicenses(), 'issue_date' => TTDate::getDate('DATE', $license->getIssueDate()), 'expire_date' => $license->getExpireDate(), 'expire_date_display' => TTDate::getDate('DATE', $license->getExpireDate()), 'registration_key' => $license->getRegistrationKey(), 'message' => $license->getFullErrorMessage($retval), 'retval' => $retval); } } //Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__,10); return $this->returnHandler($data); }
Debug::Text('Clearing Column: ' . $static_column_key, __FILE__, __LINE__, __METHOD__, 10); $rows[$last_row][Misc::trimSortPrefix($static_column_key)] = NULL; } unset($static_column_key, $static_column_val); } } } foreach ($filter_data['column_ids'] as $column_key) { $filter_columns[Misc::trimSortPrefix($column_key)] = $columns[$column_key]; } if ($action == 'display_t4s') { Debug::Text('Generating PDF: ', __FILE__, __LINE__, __METHOD__, 10); $last_row = count($rows) - 1; $total_row = $last_row + 1; //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($current_company->getId())->getCurrent(); //Debug::setVerbosity(11); $t4 = new T4(); if (isset($filter_data['include_t4_back']) and $filter_data['include_t4_back'] == 1) { $t4->setShowInstructionPage(TRUE); } //$t4->setShowBackGround(FALSE); $t4->setShowBorder(FALSE); //$t4->setXOffset(10); //$t4->setYOffset(10); $t4->setType($filter_data['type']); $t4->setYear($filter_data['year']); $t4->setBusinessNumber($company_obj->getBusinessNumber()); $t4->setCompanyName($company_obj->getName()); $t4->setCompanyAddress1($company_obj->getAddress1());
} else { $id = $current_company->getId(); $clf->GetByID($id); } foreach ($clf as $company) { //Debug::Arr($company,'Company', __FILE__, __LINE__, __METHOD__,10); $company_data = array('id' => $company->getId(), 'parent' => $company->getParent(), 'status' => $company->getStatus(), 'product_edition' => $company->getProductEdition(), 'name' => $company->getName(), 'short_name' => $company->getShortName(), 'industry_id' => $company->getIndustry(), 'business_number' => $company->getBusinessNumber(), 'originator_id' => $company->getOriginatorID(), 'data_center_id' => $company->getDataCenterID(), 'address1' => $company->getAddress1(), 'address2' => $company->getAddress2(), 'city' => $company->getCity(), 'province' => $company->getProvince(), 'country' => $company->getCountry(), 'postal_code' => $company->getPostalCode(), 'work_phone' => $company->getWorkPhone(), 'fax_phone' => $company->getFaxPhone(), 'admin_contact' => $company->getAdminContact(), 'billing_contact' => $company->getBillingContact(), 'support_contact' => $company->getSupportContact(), 'logo_file_name' => $company->getLogoFileName(NULL, FALSE), 'enable_second_last_name' => $company->getEnableSecondLastName(), 'other_id1' => $company->getOtherID1(), 'other_id2' => $company->getOtherID2(), 'other_id3' => $company->getOtherID3(), 'other_id4' => $company->getOtherID4(), 'other_id5' => $company->getOtherID5(), 'ldap_authentication_type_id' => $company->getLDAPAuthenticationType(), 'ldap_host' => $company->getLDAPHost(), 'ldap_port' => $company->getLDAPPort(), 'ldap_bind_user_name' => $company->getLDAPBindUserName(), 'ldap_bind_password' => $company->getLDAPBindPassword(), 'ldap_base_dn' => $company->getLDAPBaseDN(), 'ldap_bind_attribute' => $company->getLDAPBindAttribute(), 'ldap_user_filter' => $company->getLDAPUserFilter(), 'ldap_login_attribute' => $company->getLDAPLoginAttribute(), 'created_date' => $company->getCreatedDate(), 'created_by' => $company->getCreatedBy(), 'updated_date' => $company->getUpdatedDate(), 'updated_by' => $company->getUpdatedBy(), 'deleted_date' => $company->getDeletedDate(), 'deleted_by' => $company->getDeletedBy()); } } elseif ($action != 'submit') { $company_data = array('parent' => $current_company->getId()); } //Select box options; $company_data['status_options'] = $cf->getOptions('status'); $company_data['country_options'] = $cf->getOptions('country'); $company_data['industry_options'] = $cf->getOptions('industry'); //Company list. $company_data['company_list_options'] = CompanyListFactory::getAllArray(); $company_data['product_edition_options'] = $cf->getOptions('product_edition'); //Get other field names $oflf = TTnew('OtherFieldListFactory'); $company_data['other_field_names'] = $oflf->getByCompanyIdAndTypeIdArray($current_company->getID(), 2); $company_data['ldap_authentication_type_options'] = $cf->getOptions('ldap_authentication_type'); if (!isset($id) and isset($company_data['id'])) { $id = $company_data['id']; } $company_data['user_list_options'] = UserListFactory::getByCompanyIdArray($id); $smarty->assign_by_ref('company_data', $company_data); break; } $smarty->assign_by_ref('cf', $cf); $smarty->display('company/EditCompany.tpl');
function getPayStub($pslf = NULL, $hide_employer_rows = TRUE) { if (!is_object($pslf) and $this->getId() != '') { $pslf = new PayStubListFactory(); $pslf->getById($this->getId()); } if (get_class($pslf) !== 'PayStubListFactory') { return FALSE; } $border = 0; if ($pslf->getRecordCount() > 0) { $pdf = new TTPDF('P', 'mm', 'Letter'); $pdf->setMargins(0, 0); //$pdf->SetAutoPageBreak(TRUE, 30); $pdf->SetAutoPageBreak(FALSE); $pdf->SetFont('freeserif', '', 10); //$pdf->SetFont('FreeSans','',10); $i = 0; foreach ($pslf as $pay_stub_obj) { $psealf = new PayStubEntryAccountListFactory(); Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10); //Get Pay Period information $pplf = new PayPeriodListFactory(); $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); //Use Pay Stub dates, not Pay Period dates. $pp_start_date = $pay_stub_obj->getStartDate(); $pp_end_date = $pay_stub_obj->getEndDate(); $pp_transaction_date = $pay_stub_obj->getTransactionDate(); //Get pay period numbers $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent(); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); //Change locale to users own locale. TTi18n::setCountry($user_obj->getCountry()); TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage()); TTi18n::setLocale(); // // Pay Stub Header // $pdf->AddPage(); $adjust_x = 20; $adjust_y = 10; //Logo $pdf->Image($company_obj->getLogoFileName(), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), 50, 12, '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE); //Company name/address $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C'); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C'); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C'); //Pay Period info $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R'); $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R'); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y)); $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', 0); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y)); $pdf->setLineWidth(0.25); //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10); $description_subscript = NULL; $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); //Use this to put the total for each type at the end of the array. if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10); if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } //If type if 40 (a total) and the amount is 0, skip it. //This if the employee has no deductions at all, it won't be displayed //on the pay stub. if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) { $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); } $prev_type = $pay_stub_entry_name_obj->getType(); } //There should always be pay stub entries for a pay stub. if (!isset($pay_stub_entries)) { continue; } //Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10); //$pay_period_number = $pay_period_schedule_obj->getCurrentPayPeriodNumber( $pay_period_obj->getTransactionDate(), $pay_period_obj->getEndDate() ); $block_adjust_y = 30; // //Earnings // if (isset($pay_stub_entries[10])) { //Earnings Header $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, TTi18n::gettext('Earnings'), $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::gettext('Rate'), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[10] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 10) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(88, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(110, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(131, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(17, 5, '', $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // // Deductions // if (isset($pay_stub_entries[20])) { $max_deductions = count($pay_stub_entries[20]); //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[20] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 20) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } if (isset($pay_stub_entries[40][0])) { $block_adjust_y = $block_adjust_y + 5; //Net Pay entry $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entries[40][0]['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['ytd_amount']), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; } // //Employer Contributions // //echo "Employee Ded: <br>\n"; if (isset($pay_stub_entries[30]) and $hide_employer_rows != TRUE) { $max_deductions = count($pay_stub_entries[30]); //echo "Max Employee Ded: ". $max_deductions ."<br>\n"; //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[30] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 30) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } // //Accruals PS accounts // if (isset($pay_stub_entries[50])) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Accruals'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('Balance'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[50] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 50) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // //Accrual Policy Balances // $ablf = new AccrualBalanceListFactory(); $ablf->getByUserIdAndCompanyIdAndEnablePayStubBalanceDisplay($user_obj->getId(), $user_obj->getCompany(), TRUE); if ($ablf->getRecordCount() > 0) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $accrual_time_header_start_x = $pdf->getX(); $accrual_time_header_start_y = $pdf->getY(); $pdf->Cell(70, 5, TTi18n::gettext('Accrual Time Balances as of ') . TTDate::getDate('DATE', time()), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::gettext('Balance (hrs)'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = 5; $pdf->SetFont('', '', 10); foreach ($ablf as $ab_obj) { $balance = $ab_obj->getBalance(); if (!is_numeric($balance)) { $balance = 0; } $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(70, 5, $ab_obj->getColumn('name'), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::formatNumber(TTDate::getHours($balance)), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = $box_height + 5; unset($balance); } $pdf->Rect($accrual_time_header_start_x, $accrual_time_header_start_y, 95, $box_height); unset($accrual_time_header_start_x, $accrual_time_header_start_y, $box_height); } // //Descriptions // if (isset($pay_stub_entry_descriptions) and count($pay_stub_entry_descriptions) > 0) { //Description Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('Notes'), $border, 0, 'L'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 8); $x = 0; foreach ($pay_stub_entry_descriptions as $pay_stub_entry_description) { if ($x % 2 == 0) { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } else { $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } //$pdf->Cell(173,5, '['.$pay_stub_entry_description['subscript'].'] '.$pay_stub_entry_description['description'], $border, 0, 'L'); $pdf->Cell(85, 5, '[' . $pay_stub_entry_description['subscript'] . '] ' . $pay_stub_entry_description['description'], $border, 0, 'L'); if ($x % 2 != 0) { $block_adjust_y = $block_adjust_y + 5; } $x++; } } unset($x, $pay_stub_entry_descriptions, $pay_stub_entry_description); // // Pay Stub Footer // $block_adjust_y = 215; //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y, $adjust_y)); //Non Negotiable $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 3, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('NON NEGOTIABLE'), $border, 0, 'C', 0); //Employee Address $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 9, $adjust_y)); $pdf->Cell(60, 5, TTi18n::gettext('CONFIDENTIAL'), $border, 0, 'C', 0); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 14, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C', 0); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 19, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress1(), $border, 0, 'C', 0); $address2_adjust_y = 0; if ($user_obj->getAddress2() != '') { $address2_adjust_y = 5; $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress2(), $border, 0, 'C', 0); } $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24 + $address2_adjust_y, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 1, 'C', 0); //Pay Period - Balance - ID $net_pay_amount = 0; if (isset($pay_stub_entries[40][0])) { $net_pay_amount = $pay_stub_entries[40][0]['amount']; } if (isset($pay_stub_entries[65]) and count($pay_stub_entries[65]) > 0) { $net_pay_label = TTi18n::gettext('Balance'); } else { $net_pay_label = TTi18n::gettext('Net Pay'); } /* if ( $pay_period_schedule_obj->getType() != 5 AND $pay_period_number > 0 AND $pay_period_schedule_obj->getAnnualPayPeriods() > 0 ) { $pdf->setXY( Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y+10, $adjust_y) ); $pdf->Cell(50, 5, TTi18n::gettext('Pay Period').' '. $pay_period_number .' '. TTi18n::gettext('of') .' '. $pay_period_schedule_obj->getAnnualPayPeriods(), $border, 1, 'L', 0); } */ $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 17, $adjust_y)); $pdf->Cell(50, 5, $net_pay_label . ': ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $net_pay_amount . ' ' . $pay_stub_obj->getCurrencyObject()->getISOCode(), $border, 1, 'L', 0); if ($pay_stub_obj->getTainted() == TRUE) { $tainted_flag = 'T'; } else { $tainted_flag = ''; } $pdf->SetFont('', '', 8); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 30, $adjust_y)); $pdf->Cell(50, 5, TTi18n::gettext('Identification #:') . ' ' . str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT) . $tainted_flag, $border, 1, 'L', 0); unset($net_pay_amount, $tainted_flag); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 35, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y + 35, $adjust_y)); $pdf->SetFont('', '', 6); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 38, $adjust_y)); $pdf->Cell(175, 1, TTi18n::gettext('Pay Stub Generated by') . ' ' . APPLICATION_NAME, $border, 0, 'C', 0); unset($pay_period_schedule_obj, $pay_stub_entries, $pay_period_number); $i++; } $output = $pdf->Output('', 'S'); } TTi18n::setMasterLocale(); if (isset($output)) { return $output; } return FALSE; }
* the words "Powered by TimeTrex". ********************************************************************************/ /* * $Revision: 1396 $ * $Id: CheckForUpdate.php 1396 2007-11-07 16:49:35Z ipso $ * $Date: 2007-11-07 08:49:35 -0800 (Wed, 07 Nov 2007) $ */ /* * Checks for any version updates... * */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; $ttsc = new TimeTrexSoapClient(); if ($ttsc->isUpdateNotifyEnabled() == TRUE) { $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { $i = 0; foreach ($clf as $c_obj) { if ($ttsc->getLocalRegistrationKey() == FALSE or $ttsc->getLocalRegistrationKey() == '') { $ttsc->saveRegistrationKey(); } //We must ensure that the data is up to date //Otherwise version check will fail. $ttsc->sendCompanyData($c_obj->getId()); $ttsc->sendCompanyUserLocationData($c_obj->getId()); $ttsc->sendCompanyUserCountData($c_obj->getId()); $ttsc->sendCompanyVersionData($c_obj->getId()); //Only need to call this on the last company if ($i == $clf->getRecordCount() - 1) {
function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Configure currencies for Standard Edition. if ($this->getIsUpgrade() == TRUE) { $clf = new CompanyListFactory(); $clf->StartTransaction(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() == 10) { //Converting to new Accrual Policy table. Debug::text('Converting to new Accrual Policy Table: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $pglf = new PolicyGroupListFactory(); $pglf->getByCompanyId($c_obj->getId()); if ($pglf->getRecordCount() > 0) { foreach ($pglf as $pg_obj) { Debug::text('Accrual Policy ID: ' . $pg_obj->getColumn('accrual_policy_id'), __FILE__, __LINE__, __METHOD__, 9); if ($pg_obj->getColumn('accrual_policy_id') != '' and $pg_obj->getColumn('accrual_policy_id') != 0) { $pg_obj->setAccrualPolicy(array($pg_obj->getColumn('accrual_policy_id'))); if ($pg_obj->isValid()) { $pg_obj->Save(); } } } } Debug::text('Adding Currency Information to Company: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($c_obj->getId()); if ($crlf->getRecordCount() == 0) { $cf = new CurrencyFactory(); $country_to_currency_map_arr = $cf->getOptions('country_currency'); if (isset($country_to_currency_map_arr[$c_obj->getCountry()])) { $base_currency = $country_to_currency_map_arr[$c_obj->getCountry()]; Debug::text('Found Base Currency For Country: ' . $c_obj->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9); } else { Debug::text('DID NOT Find Base Currency For Country: ' . $c_obj->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9); $base_currency = 'USD'; } $cf->setCompany($c_obj->getId()); $cf->setStatus(10); $cf->setName($base_currency); $cf->setISOCode($base_currency); $cf->setConversionRate('1.000000000'); $cf->setAutoUpdate(FALSE); $cf->setBase(TRUE); $cf->setDefault(TRUE); if ($cf->isValid()) { $base_currency_id = $cf->Save(); Debug::text('Base Currency ID: ' . $base_currency_id, __FILE__, __LINE__, __METHOD__, 10); //Set Employee Hire Defaults. $udlf = new UserDefaultListFactory(); $udlf->getByCompanyId($c_obj->getId()); if ($udlf->getRecordCount() > 0) { $ud_obj = $udlf->getCurrent(); $ud_obj->setCurrency($base_currency_id); $ud_obj->setLanguage('en'); if ($ud_obj->isValid()) { $ud_obj->Save(); } } unset($udlf, $ud_obj); if (is_numeric($base_currency_id)) { $ulf = new UserListFactory(); $ulf->getByCompanyId($c_obj->getId()); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $u_obj) { $user_id = $u_obj->getID(); Debug::text('Setting Base Currency For User: '******' ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); $u_obj->setCurrency($base_currency_id); if ($u_obj->isValid()) { if ($u_obj->Save() == TRUE) { //Set User Default Language $uplf = new UserPreferenceListFactory(); $uplf->getByUserIDAndCompanyID($user_id, $c_obj->getId()); if ($uplf->getRecordCount() > 0) { $up_obj = $uplf->getCurrent(); $up_obj->setLanguage('en'); //Englist if ($up_obj->isValid()) { $up_obj->Save(); } } unset($uplf, $up_obj); Debug::text(' Setting Base Currency for Pay Stubs, User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); //Change all pay stubs for this user to the base currency. //Do this in a single query for speed purposes. $ph = array('currency_id' => $base_currency_id, 'currency_rate' => '1.000000000', 'user_id' => $user_id); $query = 'update pay_stub set currency_id = ?, currency_rate = ? where user_id = ?'; Debug::text(' Pay Stub Currency Query: ' . $query, __FILE__, __LINE__, __METHOD__, 10); $u_obj->db->Execute($query, $ph); /* $pslf = new PayStubListFactory(); $pslf->getByUserIdAndCompanyId( $user_id, $c_obj->getId() ); if ( $pslf->getRecordCount() > 0 ) { foreach( $pslf as $ps_obj ) { //Debug::text(' Setting Base Currency for Pay Stub ID: '. $ps_obj->getId(), __FILE__, __LINE__, __METHOD__,10); $ps_obj->setCurrency( $base_currency_id ); if ( $ps_obj->isValid() ) { $ps_obj->setEnableLinkedAccruals( FALSE ); $ps_obj->setEnableCalcYTD( FALSE ); $ps_obj->setEnableProcessEntries( FALSE ); $ps_obj->Save(); } unset($ps_obj); } } unset($pslf); */ } else { Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); } unset($u_obj, $user_id); } } unset($ulf); } } unset($cf); } } else { Debug::text('Company is not active! ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); } unset($c_obj, $base_currency, $base_currency_id, $crlf); } } //$clf->FailTransaction(); $clf->CommitTransaction(); } //Add currency updating 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 = new CronJobFactory(); $cjf->setName('UpdateCurrencyRates'); $cjf->setMinute(45); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand($cron_job_base_command . 'UpdateCurrencyRates.php'); $cjf->Save(); return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Copy iButton,Fingerprint,EmployeeNumber (barcode/proximity) fields to new UserIdentification table. //Find out if they have both TimeClocks and FingerPrint stations. If they do //we need to copy the fingerprint data to both types of UserIdentification rows. $clf = new CompanyListFactory(); $clf->getAll(); $clf->StartTransaction(); foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $max_templates = 4; $slf = new StationListFactory(); $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(30, 40, 50, 100, 110)); if ($slf->getRecordCount() > 0) { $slf_tmp1 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(50)); $griaule_stations = $slf_tmp1->getRecordCount(); Debug::text(' Found Griaule Stations: ' . $griaule_stations, __FILE__, __LINE__, __METHOD__, 9); unset($slf_tmp1); $slf_tmp2 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(100, 110)); $zk_stations = $slf_tmp2->getRecordCount(); Debug::text(' Found ZK Stations: ' . $zk_stations, __FILE__, __LINE__, __METHOD__, 9); unset($slf_tmp2); $slf_tmp3 = $slf->getByCompanyIdAndTypeId($c_obj->getId(), array(40)); $barcode_stations = $slf_tmp3->getRecordCount(); Debug::text(' Found Barcode Stations: ' . $barcode_stations, __FILE__, __LINE__, __METHOD__, 9); unset($slf_tmp3); //Loop through each user copying their data to the UserIdenfification Table. $ulf = new UserListFactory(); $ulf->getByCompanyID($c_obj->getId()); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $u_obj) { Debug::text(' User: '******'') { Debug::text(' Converting iButton...', __FILE__, __LINE__, __METHOD__, 9); $uif = new UserIdentificationFactory(); $uif->setUser($u_obj->getId()); $uif->setType(10); //10=iButton $uif->setNumber(0); $uif->setValue($u_obj->getIButtonID()); if ($uif->isValid() == TRUE) { $uif->Save(); $u_obj->getIButtonID(''); } } if ($u_obj->getRFID() != '') { Debug::text(' Converting RFID...', __FILE__, __LINE__, __METHOD__, 9); $uif = new UserIdentificationFactory(); $uif->setUser($u_obj->getId()); $uif->setType(40); //40=Proximity $uif->setNumber(0); $uif->setValue($u_obj->getRFID()); if ($uif->isValid() == TRUE) { $uif->Save(); $u_obj->getRFID(''); } } if ($barcode_stations > 0 and $u_obj->getEmployeeNumber() != '') { Debug::text(' Converting EmployeeNumber...', __FILE__, __LINE__, __METHOD__, 9); $uif = new UserIdentificationFactory(); $uif->setUser($u_obj->getId()); $uif->setType(30); //30=Barcode $uif->setNumber(0); $uif->setValue($u_obj->getEmployeeNumber()); if ($uif->isValid() == TRUE) { $uif->Save(); } } if ($griaule_stations > 0) { for ($t = 1; $t <= $max_templates; $t++) { $set_fingerprint_function = 'setFingerPrint' . $t; $get_fingerprint_function = 'getFingerPrint' . $t; //Griaule fingerprint templates start with: "p/8B" if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 4) == 'p/8B') { Debug::text(' Converting Griaule FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9); $uif = new UserIdentificationFactory(); $uif->setUser($u_obj->getId()); $uif->setType(20); //20=Griaule, 100=ZK $uif->setNumber($t * 10); $uif->setValue($u_obj->{$get_fingerprint_function}()); if ($uif->isValid() == TRUE) { $uif->Save(); $u_obj->{$set_fingerprint_function}(''); } } } } if ($zk_stations > 0) { for ($t = 1; $t <= $max_templates; $t++) { $set_fingerprint_function = 'setFingerPrint' . $t; $get_fingerprint_function = 'getFingerPrint' . $t; //ZK fingerprint templates start with: "oco" if ($u_obj->{$get_fingerprint_function}() != '' and substr($u_obj->{$get_fingerprint_function}(), 0, 3) == 'oco') { Debug::text(' Converting ZK FingerPrint: ' . $t, __FILE__, __LINE__, __METHOD__, 9); $uif = new UserIdentificationFactory(); $uif->setUser($u_obj->getId()); $uif->setType(100); //20=Griaule, 100=ZK $uif->setNumber($t); $uif->setValue($u_obj->{$get_fingerprint_function}()); if ($uif->isValid() == TRUE) { $uif->Save(); $u_obj->{$set_fingerprint_function}(''); } } } } if ($u_obj->isValid()) { $u_obj->Save(); } } } } } $clf->CommitTransaction(); return TRUE; }
static function addPresets($company_id) { if ($company_id == '') { return FALSE; } $clf = new CompanyListFactory(); $clf->getById($company_id); if ($clf->getRecordCount() > 0) { $company_obj = $clf->getCurrent(); $country = $company_obj->getCountry(); $province = $company_obj->getProvince(); } else { return FALSE; } $pseaf = new PayStubEntryAccountFactory(); $pseaf->StartTransaction(); /* 10 => 'Earning', 20 => 'Employee Deduction', 30 => 'Employer Deduction', 40 => 'Total', 50 => 'Accrual', 60 => 'Advance Earning', 65 => 'Advance Deduction', */ //See if accounts are already linked $pseallf = new PayStubEntryAccountLinkListFactory(); $pseallf->getByCompanyId($company_id); if ($pseallf->getRecordCount() > 0) { $psealf = $pseallf->getCurrent(); } else { $psealf = new PayStubEntryAccountLinkFactory(); $psealf->setCompany($company_id); } Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10); switch (strtolower($country)) { case 'ca': Debug::text('Saving.... Federal Taxes', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Federal Income Tax'); $pseaf->setOrder(210); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Provincial Income Tax'); $pseaf->setOrder(220); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Additional Income Tax'); $pseaf->setOrder(230); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('CPP'); $pseaf->setOrder(240); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setEmployeeCPP($psea_id); unset($psea_id); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('EI'); $pseaf->setOrder(250); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setEmployeeEI($psea_id); unset($psea_id); } //Employer Contributions $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('CPP - Employer'); $pseaf->setOrder(300); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('EI - Employer'); $pseaf->setOrder(310); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('WCB - Employer'); $pseaf->setOrder(320); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Vacation Accrual', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(50); $pseaf->setName('Vacation Accrual'); $pseaf->setOrder(400); if ($pseaf->isValid()) { $vacation_accrual_id = $pseaf->Save(); Debug::text('Saving.... Earnings - Vacation Accrual Release', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Vacation Accrual Release'); $pseaf->setOrder(180); $pseaf->setAccrual($vacation_accrual_id); if ($pseaf->isValid()) { $pseaf->Save(); } unset($vaction_accrual_id); } break; case 'us': $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Federal Income Tax'); $pseaf->setOrder(210); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Advance EIC'); $pseaf->setOrder(215); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('State Income Tax'); $pseaf->setOrder(220); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('District Income Tax'); $pseaf->setOrder(225); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Federal Add. Income Tax'); $pseaf->setOrder(230); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('State Add. Income Tax'); $pseaf->setOrder(235); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Social Security (FICA)'); $pseaf->setOrder(240); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('Social Security (FICA)'); $pseaf->setOrder(340); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('Fed. Unemployment Ins.'); $pseaf->setOrder(342); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('State Unemployment Ins.'); $pseaf->setOrder(240); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Medicare'); $pseaf->setOrder(245); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('Medicare'); $pseaf->setOrder(346); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('State Disability Ins.'); $pseaf->setOrder(250); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('State Unemployment Ins.'); $pseaf->setOrder(350); if ($pseaf->isValid()) { $pseaf->Save(); } $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('State Employee Training'); $pseaf->setOrder(352); if ($pseaf->isValid()) { $pseaf->Save(); } break; } Debug::text('Province: ' . $province, __FILE__, __LINE__, __METHOD__, 10); switch (strtolower($province)) { case 'ny': $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('State Reemployment'); $pseaf->setOrder(354); if ($pseaf->isValid()) { $pseaf->Save(); } break; } Debug::text('Saving.... Earnings - Regular Time', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Regular Time'); $pseaf->setOrder(100); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setRegularTime($psea_id); unset($psea_id); } Debug::text('Saving.... Earnings - Over Time 1', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Over Time 1'); $pseaf->setOrder(150); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Earnings - Over Time 2', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Over Time 2'); $pseaf->setOrder(151); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Earnings - Premium Time 1', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Premium 1'); $pseaf->setOrder(170); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Earnings - Premium Time 2', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Premium 2'); $pseaf->setOrder(171); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Earnings - Bonus', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Bonus'); $pseaf->setOrder(185); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Earnings - Other', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(10); $pseaf->setName('Other'); $pseaf->setOrder(189); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Union Dues', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Union Dues'); $pseaf->setOrder(285); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Employee Benefits Plan', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(20); $pseaf->setName('Benefits Plan'); $pseaf->setOrder(225); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Employer Benefits Plan', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(30); $pseaf->setName('Benefits Plan'); $pseaf->setOrder(330); if ($pseaf->isValid()) { $pseaf->Save(); } Debug::text('Saving.... Total Earnings', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(40); $pseaf->setName('Total Gross'); $pseaf->setOrder(199); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setTotalGross($psea_id); unset($psea_id); } Debug::text('Saving.... Total Deductions', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(40); $pseaf->setName('Total Deductions'); $pseaf->setOrder(298); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setTotalEmployeeDeduction($psea_id); unset($psea_id); } Debug::text('Saving.... Net Pay', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(40); $pseaf->setName('Net Pay'); $pseaf->setOrder(299); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setTotalNetPay($psea_id); unset($psea_id); } Debug::text('Saving.... Employer Total Cont', __FILE__, __LINE__, __METHOD__, 10); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany($company_id); $pseaf->setStatus(10); $pseaf->setType(40); $pseaf->setName('Employer Total Contributions'); $pseaf->setOrder(399); if ($pseaf->isValid()) { $psea_id = $pseaf->Save(); $psealf->setTotalEmployerDeduction($psea_id); unset($psea_id); } if ($psealf->isValid() == TRUE) { Debug::text('Saving.... PSA Linking', __FILE__, __LINE__, __METHOD__, 10); $psealf->Save(); } else { Debug::text('Saving.... PSA Linking FAILED!', __FILE__, __LINE__, __METHOD__, 10); } $pseaf->CommitTransaction(); //$pseaf->FailTransaction(); return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through all pay period schedules and update the annual pay period column $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getAll(); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $pps_obj->setAnnualPayPeriods($pps_obj->calcAnnualPayPeriods()); if ($pps_obj->isValid()) { $pps_obj->Save(); } } } //Go through all employee wages and update HourlyRate to the accurate annual hourly rate. //**Handle this in 1034A postInstall() instead, as it needs to handle incorrect effective_dates properly. /* $uwlf = new UserWageListFactory(); $uwlf->getAll(); if ( $uwlf->getRecordCount() > 0 ) { foreach( $uwlf as $uw_obj ) { $uw_obj->setHourlyRate( $uw_obj->calcHourlyRate( time(), TRUE ) ); if ( $uw_obj->isValid() ) { $uw_obj->Save(); } } } */ //Upgrade to new hierarchy format. $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { /* if ( !($c_obj->getId() == 1052) ) { //$c_obj->getId() == 1009 OR $c_obj->getId() == 1087 OR continue; } */ $company_id = $c_obj->getId(); Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); $hclf = new HierarchyControlListFactory(); $hclf->StartTransaction(); $hclf->getByCompanyId($company_id); if ($hclf->getRecordCount() > 0) { foreach ($hclf as $hc_obj) { $paths_to_root = array(); $hierarchy_id = $hc_obj->getId(); $hlf = new HierarchyListFactory(); $hierarchy_users = $hlf->getByCompanyIdAndHierarchyControlId($company_id, $hierarchy_id); if (is_array($hierarchy_users) and count($hierarchy_users) > 0) { $hotlf = new HierarchyObjectTypeListFactory(); $hotlf->getByHierarchyControlId($hierarchy_id); if ($hotlf->getRecordCount() > 0) { foreach ($hotlf as $hot_obj) { $object_types[$hierarchy_id][] = $hot_obj->getObjectType(); } } foreach ($hierarchy_users as $hierarchy_user_arr) { Debug::Text(' Checking User ID: ' . $hierarchy_user_arr['id'], __FILE__, __LINE__, __METHOD__, 10); $id = $hierarchy_user_arr['id']; $tmp_id = $id; $i = 0; do { Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10); $hlf_b = new HierarchyListFactory(); $parents = $hlf_b->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id); sort($parents); $level = $hlf_b->getFastTreeObject()->getLevel($tmp_id) - 1; if (is_array($parents) and count($parents) > 0) { $parent_users = array(); foreach ($parents as $user_id) { $parent_users[] = $user_id; unset($user); } $parent_groups[$level] = $parent_users; unset($parent_users); } if (isset($parents[0])) { $tmp_id = $parents[0]; } $i++; } while (is_array($parents) and count($parents) > 0 and $i < 100); if (isset($parent_groups)) { $serialized_path = serialize($parent_groups); $paths_to_root[$serialized_path][] = $id; unset($serialized_path); } unset($parent_groups, $parents); } } Debug::Arr($paths_to_root, ' Paths To Root: ', __FILE__, __LINE__, __METHOD__, 10); //Decode path_to_root array if (isset($paths_to_root) and count($paths_to_root) > 0) { foreach ($paths_to_root as $serialized_path => $children) { $path_arr = unserialize($serialized_path); $decoded_paths[] = array('hierarchy_control_id' => $hierarchy_id, 'path' => $path_arr, 'children' => $children); } unset($path_arr, $children); Debug::Arr($decoded_paths, ' Decoded Paths: ', __FILE__, __LINE__, __METHOD__, 10); if (isset($decoded_paths) and is_array($decoded_paths)) { foreach ($decoded_paths as $decoded_path) { Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); //Create new hierarchy_control $hcf = new HierarchyControlFactory(); $hcf->setCompany($company_id); $hcf->setObjectType($object_types[$decoded_path['hierarchy_control_id']]); //Generate meaningful name $name = FALSE; if (isset($decoded_path['path']) and is_array($decoded_path['path'])) { ksort($decoded_path['path']); //Sort by level. foreach ($decoded_path['path'] as $level => $superior_ids) { foreach ($superior_ids as $superior_id) { $ulf = new UserListFactory(); $ulf->getById($superior_id); if ($ulf->getRecordCount() > 0) { $name[] = $level . '. ' . $ulf->getCurrent()->getFullName(); } } } unset($level, $superior_ids, $superior_id); } if (isset($name)) { $name = $hc_obj->getName() . ' ' . implode(', ', $name) . ' (#' . rand(1000, 9999) . ')'; } else { $name = $hc_obj->getName() . ' (#' . rand(1000, 9999) . ')'; } $hcf->setName(substr($name, 0, 249)); $hcf->setDescription(TTi18n::getText('Automatically created by TimeTrex')); if ($hcf->isValid()) { $hc_id = $hcf->Save(FALSE); Debug::Text('Hierarchy Control ID: ' . $hc_id, __FILE__, __LINE__, __METHOD__, 10); $hcf->setUser($decoded_path['children']); if (isset($decoded_path['path']) and is_array($decoded_path['path'])) { foreach ($decoded_path['path'] as $level => $superior_ids) { foreach ($superior_ids as $superior_id) { $hlf = new HierarchyLevelFactory(); $hlf->setHierarchyControl($hc_id); $hlf->setLevel($level); $hlf->setUser($superior_id); if ($hlf->isValid()) { $hlf->Save(); Debug::Text('Saving Level Row ID... User ID: ' . $superior_id, __FILE__, __LINE__, __METHOD__, 10); } } } unset($level, $superior_ids, $superior_id); } } } } unset($decoded_paths); } //Delete existing hierarchy control. $hc_obj->setDeleted(TRUE); if ($hc_obj->isValid() == TRUE) { $hc_obj->Save(); } } } //$hclf->FailTransaction(); $hclf->CommitTransaction(); } } } //Go through each permission group, and enable break policies for anyone who can see meal policies $clf = new 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 = new PermissionControlListFactory(); $pclf->getByCompanyId($c_obj->getId()); if ($pclf->getRecordCount() > 0) { foreach ($pclf as $pc_obj) { Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $plf = new PermissionListFactory(); $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'meal_policy', 'enabled'); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with meal policy enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('break_policy' => array('enabled' => TRUE, 'view' => TRUE, 'add' => TRUE, 'edit' => TRUE, 'delete' => TRUE))); } else { Debug::text('Permission group does NOT have meal policy enabled...', __FILE__, __LINE__, __METHOD__, 9); } } } } } } //Add MiscDaily cronjob to database. $cjf = new CronJobFactory(); $cjf->setName('MiscDaily'); $cjf->setMinute(55); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand('MiscDaily.php'); $cjf->Save(); //Add MiscWeekly cronjob to database. $cjf = new CronJobFactory(); $cjf->setName('MiscWeekly'); $cjf->setMinute(55); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('0'); //Sunday morning. $cjf->setCommand('MiscWeekly.php'); $cjf->Save(); return TRUE; }
} //Import all data $import_arr = Misc::parseCSV($import_csv_file, TRUE, FALSE, ",", 9216, 0); if (!is_array($import_arr)) { echo "Parsing CSV file failed!\n"; } else { echo "Importing Users...\n"; $uf = new UserFactory(); $uf->StartTransaction(); $commit_trans = TRUE; $i = 1; $e = 0; foreach ($import_arr as $tmp_import_arr) { $mapped_row = Misc::importApplyColumnMap($filtered_import_map, $tmp_import_arr); if ($i == 1 and $mapped_row['company_id'] > 0) { $clf = new CompanyListFactory(); $clf->getById($mapped_row['company_id']); if ($clf->getRecordCount() > 0) { echo 'Company: ' . $clf->getCurrent()->getName() . "\n"; ob_flush(); flush(); sleep(2); } unset($clf); } $uf = new UserFactory(); //Start with user default values. $udlf = new UserDefaultListFactory(); $udlf->getByCompanyId($mapped_row['company_id']); if ($udlf->getRecordCount() > 0) { Debug::Text('Using User Defaults', __FILE__, __LINE__, __METHOD__, 10);
function getAllArray() { $clf = new CompanyListFactory(); $clf->getAll(); $company_list[0] = '--'; foreach ($clf as $company) { $company_list[$company->getID()] = $company->getName(); } return $company_list; }
$department_options = $dlf->getByCompanyIdArray($company_id); $culf = new CurrencyListFactory(); $culf->getByCompanyId($company_id); $currency_options = $culf->getArrayByListFactory($culf, FALSE, TRUE); $hotf = new HierarchyObjectTypeFactory(); $hierarchy_object_type_options = $hotf->getOptions('object_type'); $hclf = new HierarchyControlListFactory(); $hclf->getObjectTypeAppendedListByCompanyID($company_id); $hierarchy_control_options = $hclf->getArrayByListFactory($hclf, TRUE, TRUE); //Select box options; $user_data['branch_options'] = $branch_options; $user_data['department_options'] = $department_options; $user_data['currency_options'] = $currency_options; $user_data['sex_options'] = $uf->getOptions('sex'); $user_data['status_options'] = $uf->getOptions('status'); $clf = new CompanyListFactory(); $user_data['country_options'] = $clf->getOptions('country'); $user_data['province_options'] = $clf->getOptions('province', $user_data['country']); $utlf = new UserTitleListFactory(); $user_titles = $utlf->getByCompanyIdArray($company_id); $user_data['title_options'] = $user_titles; //Get Permission Groups $pclf = new PermissionControlListFactory(); $pclf->getByCompanyId($company_id); $user_data['permission_control_options'] = $pclf->getArrayByListFactory($pclf, FALSE); //Get pay period schedules $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedules = $ppslf->getByCompanyIDArray($company_id); $user_data['pay_period_schedule_options'] = $pay_period_schedules; $pglf = new PolicyGroupListFactory(); $policy_groups = $pglf->getByCompanyIDArray($company_id);
$ulf->getSearchByArrayCriteria($filter_data, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); } else { if ($permission->Check('user', 'view') == FALSE) { if ($permission->Check('user', 'view_child')) { $filter_data['permission_children_ids'] = $permission_children_ids; } if ($permission->Check('user', 'view_own')) { $filter_data['permission_children_ids'][] = $current_user->getId(); } } Debug::Text('Users in company only!', __FILE__, __LINE__, __METHOD__, 10); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); } $pager = new Pager($ulf); if ($permission->Check('company', 'view')) { $clf = new CompanyListFactory(); $clf->getAll($current_company->getId()); $company_options = $clf->getArrayByListFactory($clf, FALSE, TRUE); } //Get title list, $utlf = new UserTitleListFactory(); $utlf->getByCompanyId($current_company->getId()); $title_options = $utlf->getArrayByListFactory($utlf, FALSE, TRUE); $blf = new BranchListFactory(); $blf->getByCompanyId($current_company->getId()); $branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE); $dlf = new DepartmentListFactory(); $dlf->getByCompanyId($current_company->getId()); $department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE); $uglf = new UserGroupListFactory(); $group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE));
$pp_end_date = $pay_period_obj->getAdvanceEndDate(); $pp_transaction_date = $pay_period_obj->getAdvanceTransactionDate(); } else { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getEndDate(); $pp_transaction_date = $pay_period_obj->getTransactionDate(); } //Get pay period numbers $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent(); $pay_period_data = array('advance' => $pay_stub_obj->getAdvance(), 'start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date), 'annual_pay_periods' => $pay_period_schedule_obj->getAnnualPayPeriods()); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); //} //Figure out how much white space we need to fill the entire page. $max_rows = 29; //With borders you gotta drop this down to 28. $total_rows = floor($pself->getRecordCount() + $description_subscript_counter); if ($pay_stub_obj->getAdvance() === FALSE) { //$total_rows -= 1; $total_rows += 1; } if ($description_subscript_counter > 1) { $total_rows += 2; } $max_types = 6; $total_types = count($pay_stub['entries']);
function getData() { $psenlf = new PayStubEntryNameListFactory(); $pslf = new PayStubListFactory(); //$pslf->getByIdAndUserId($id, $current_user->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); $pslf->getById($this->pay_stub_id); $pager = new Pager($pslf); foreach ($pslf as $pay_stub_obj) { //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { $description_subscript = NULL; $pay_stub_entry_name_obj = $psenlf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } $this->pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getDescription(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); $prev_type = $pay_stub_entry_name_obj->getType(); } //'entries' => $pay_stub_entries, $this->pay_stub = array('id' => $pay_stub_obj->getId(), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'advance' => $pay_stub_obj->getAdvance(), 'status' => $pay_stub_obj->getStatus(), 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy()); //Get Pay Period information $pplf = new PayPeriodListFactory(); $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); if ($pay_stub_obj->getAdvance() == TRUE) { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getAdvanceEndDate(); $pp_transaction_date = $pay_period_obj->getAdvanceTransactionDate(); } else { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getEndDate(); $pp_transaction_date = $pay_period_obj->getTransactionDate(); } $this->pay_period = array('start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date)); //Get User information $ulf = new UserListFactory(); $this->user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $this->company_obj = $clf->getById($this->user_obj->getCompany())->getCurrent(); } }
Debug::text('Parse License RetVal: ' . (int) $parse_license_retval . ' Validate License RetVal: ' . $validate_license_retval, __FILE__, __LINE__, __METHOD__, 9); if ($parse_license_retval === TRUE) { $sslf = new SystemSettingListFactory(); $sslf->getByName('license'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent(); } else { $obj = new SystemSettingListFactory(); } $obj->setName('license'); $obj->setValue($license_data); if ($obj->isValid()) { Debug::text('Setting License Data...', __FILE__, __LINE__, __METHOD__, 9); $obj->Save(); //Save company name from license file. $clf = new CompanyListFactory(); $clf->getById($license->getPrimaryCompanyID()); if ($clf->getRecordCount() > 0) { $c_obj = $clf->getCurrent(); } else { $c_obj = $current_company; } $c_obj->setName($license->getOrganizationName(), TRUE); if ($c_obj->isValid()) { $c_obj->Save(); } //Save registration key $sslf = new SystemSettingListFactory(); $sslf->getByName('registration_key'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent();
function checkCompanyStatus($user_name) { $ulf = new UserListFactory(); $ulf->getByUserName(strtolower($user_name)); if ($ulf->getRecordCount() == 1) { $u_obj = $ulf->getCurrent(); if (is_object($u_obj)) { $clf = new CompanyListFactory(); $clf->getById($u_obj->getCompany()); if ($clf->getRecordCount() == 1) { if ($clf->getCurrent()->getStatus() == 10) { return TRUE; } } } } return FALSE; }
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; }
function getCompanyObject() { $clf = new CompanyListFactory(); $current_company = $clf->getByID($this->getUserObject()->getCompany())->getCurrent(); return $current_company; }
static function addPresets($company_id) { if ($company_id == '') { Debug::text('Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $clf = new CompanyListFactory(); $clf->getById($company_id); if ($clf->getRecordCount() > 0) { $company_obj = $clf->getCurrent(); $country = $company_obj->getCountry(); $province = $company_obj->getProvince(); } else { Debug::text('bCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); return FALSE; } //Get PayStub Link accounts $pseallf = new PayStubEntryAccountLinkListFactory(); $pseallf->getByCompanyId($company_id); if ($pseallf->getRecordCount() > 0) { $psea_obj = $pseallf->getCurrent(); } else { Debug::text('cCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); return FALSE; } require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php'; $cdf = new CompanyDeductionFactory(); $cdf->StartTransaction(); /* 10 => 'Percent', 15 => 'Advanced Percent', 20 => 'Fixed Amount', //Federal 100 => 'Federal Income Tax Formula', //Province/State 200 => 'Province/State Income Tax Formula', 210 => 'Province/State UI Formula', */ Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10); switch (strtolower($country)) { case 'ca': $pd_obj = new PayrollDeduction($country, 'BC'); //Pick default province for now. $pd_obj->setDate(time()); $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Federal Income Tax'); $cdf->setCalculation(100); $cdf->setCalculationOrder(100); $cdf->setCountry('CA'); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%')); $cdf->setUserValue1($pd_obj->getBasicFederalClaimCodeAmount()); if ($cdf->isValid()) { $cdf->Save(FALSE); $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union')); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); //var_dump($exclude_ids); $cdf->setExcludePayStubEntryAccount($exclude_ids); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Additional Income Tax'); $cdf->setCalculation(20); $cdf->setCalculationOrder(105); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Additional Income Tax%')); $cdf->setUserValue1(0); if ($cdf->isValid()) { $cdf->Save(FALSE); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('CPP - Employee'); $cdf->setCalculation(90); // CPP Formula $cdf->setCalculationOrder(80); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP')); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('CPP - Employer'); $cdf->setCalculation(10); $cdf->setCalculationOrder(85); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%CPP - Employer%')); $cdf->setUserValue1(100); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP'))); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('EI - Employee'); $cdf->setCalculation(91); //EI Formula $cdf->setCalculationOrder(90); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI')); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('EI - Employer'); $cdf->setCalculation(10); $cdf->setCalculationOrder(95); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%EI - Employer%')); $cdf->setUserValue1(140); //2006 if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI'))); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('WCB - Employer'); $cdf->setCalculation(15); $cdf->setCalculationOrder(95); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%WCB%')); $cdf->setUserValue1(0.0); //Default $cdf->setUserValue2(0); //Annual Wage Base: WCB has this, but can differ between rates/classifications. $cdf->setUserValue3(0); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(20); //Deduction $cdf->setName('Vacation Accrual'); $cdf->setCalculation(10); $cdf->setCalculationOrder(50); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 50, 'Vacation Accrual')); $cdf->setUserValue1(4); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time')); $cdf->setExcludePayStubEntryAccount($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(20); //Deduction $cdf->setName('Vacation Release'); $cdf->setCalculation(10); $cdf->setCalculationOrder(51); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release')); $cdf->setUserValue1(4); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time')); $cdf->setExcludePayStubEntryAccount($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'us': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Federal Income Tax'); $cdf->setCalculation(100); $cdf->setCalculationOrder(100); $cdf->setCountry('US'); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%')); $cdf->setUserValue1(10); //Single $cdf->setUserValue2(1); //0 Allowances if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Advance Earned Income Credit (EIC)'); $cdf->setCalculation(80); $cdf->setCalculationOrder(105); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Advance EIC%')); $cdf->setUserValue1(10); //Single if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Federal Unemployment Insurance - Employer'); $cdf->setCalculation(15); $cdf->setCalculationOrder(80); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Fed. Unemployment Ins.')); $cdf->setUserValue1(0.8); //2009 $cdf->setUserValue2(7000); $cdf->setUserValue3(0); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Social Security - Employee'); $cdf->setCalculation(15); $cdf->setCalculationOrder(80); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)')); $cdf->setUserValue1(6.2); //2009 $cdf->setUserValue2(106800); $cdf->setUserValue3(0); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Social Security - Employer'); $cdf->setCalculation(10); $cdf->setCalculationOrder(85); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Social Security%')); $cdf->setUserValue1(100); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)'))); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Medicare - Employee'); $cdf->setCalculation(10); $cdf->setCalculationOrder(90); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare')); $cdf->setUserValue1(1.45); //2009 if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('Medicare - Employer'); $cdf->setCalculation(10); $cdf->setCalculationOrder(95); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Medicare')); $cdf->setUserValue1(100); if ($cdf->isValid()) { $cdf->Save(FALSE); //$cdf->setIncludePayStubEntryAccount( array( $psea_obj->getTotalGross() )); $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare'))); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'cr': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(TTi18n::gettext('Income Tax')); $cdf->setCalculation(100); $cdf->setCalculationOrder(100); $cdf->setCountry('CR'); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%')); $cdf->setUserValue1(10); //Single $cdf->setUserValue2(0); //0 Allowances if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; } $pd_obj = new PayrollDeduction($country, $province); $pd_obj->setDate(time()); Debug::text('Province/State: ' . $province, __FILE__, __LINE__, __METHOD__, 10); switch (strtolower($province)) { //Canada case 'ab': case 'bc': case 'sk': case 'mb': case 'qc': case 'on': case 'nl': case 'nb': case 'ns': case 'pe': case 'nt': case 'yt': case 'nu': $provincial_claim_amount = $pd_obj->getBasicProvinceClaimCodeAmount(); break; //US //US case 'al': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ak': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employer'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(32700); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employee'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(32700); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ar': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(10000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'az': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Job Training'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training')); $cdf->setUserValue1(0.1); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ca': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Disability Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(180); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.')); $cdf->setUserValue1(1.1); //2009 $cdf->setUserValue2(90669); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Employee Training'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training')); $cdf->setUserValue1(0.1); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'co': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(10000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ct': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(15000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'dc': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'de': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(10500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'fl': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ga': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'hi': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(13000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ia': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(23700); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'id': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(33200); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'il': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins. - Employer')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(12300); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'in': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ks': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ky': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'la': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ma': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(14000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'md': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'me': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(12000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'mi': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'mn': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(26000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'mo': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(12500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ms': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'mt': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(25100); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nc': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(19300); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nd': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(23700); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nh': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ne': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nj': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(28900); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(28900); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nm': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(20900); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'nv': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(26600); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ny': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0); //2009 $cdf->setUserValue2(8500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Reemployment Service Fund'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Reemployment')); $cdf->setUserValue1(0.075); //2009 $cdf->setUserValue2(8500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Disability Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(180); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.')); $cdf->setUserValue1(0.5); //2009 $cdf->setUserValue2(0); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'oh': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ok': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(14200); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'or': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Insurance')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(31300); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'pa': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ri': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Employment Security'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(18000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'sc': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'sd': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(9500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'tn': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(7000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'tx': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0); //2009 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Employee Training'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training')); $cdf->setUserValue1(0.0); //2006 $cdf->setUserValue2(9000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'ut': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(27800); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'va': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'vt': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'wa': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(37500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'wi': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(12000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'wv': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(8000); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; case 'wy': $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Unemployment Insurance'); $cdf->setCalculation(15); $cdf->setCalculationOrder(185); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.')); $cdf->setUserValue1(0.0); //2009 $cdf->setUserValue2(21500); if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } break; } if ($country == 'CA') { $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName(strtoupper($province) . ' - Provincial Income Tax'); $cdf->setCalculation(200); $cdf->setCalculationOrder(110); $cdf->setCountry('CA'); $cdf->setProvince(strtoupper($province)); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Provincial Income%')); $cdf->setUserValue1($provincial_claim_amount); if ($cdf->isValid()) { $cdf->Save(FALSE); $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union')); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); $cdf->setExcludePayStubEntryAccount($exclude_ids); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } } elseif ($country = 'US') { $cdf = new CompanyDeductionFactory(); $cdf->setCompany($company_id); $cdf->setStatus(10); //Enabled $cdf->setType(10); //Tax $cdf->setName('State Income Tax'); $cdf->setCalculation(200); $cdf->setCalculationOrder(200); $cdf->setCountry('US'); $cdf->setProvince(strtoupper($province)); $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%State Income%')); $cdf->setUserValue1(10); //Single $cdf->setUserValue2(1); //0 Allowances if ($cdf->isValid()) { $cdf->Save(FALSE); $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross())); unset($exclude_ids); if ($cdf->isValid()) { $cdf->Save(); } } } $cdf->CommitTransaction(); //$cdf->FailTransaction(); return TRUE; }
$country = $current_company->getCountry(); } else { $permission->Redirect(FALSE); } if (!isset($action)) { BreadCrumb::setCrumb($title); foreach ($balf as $bank_account) { //Debug::Arr($department,'Department', __FILE__, __LINE__, __METHOD__,10); $bank_data = array('id' => $bank_account->getId(), 'country' => strtolower($country), 'institution' => $bank_account->getInstitution(), 'transit' => $bank_account->getTransit(), 'account' => $bank_account->getAccount(), 'created_date' => $bank_account->getCreatedDate(), 'created_by' => $bank_account->getCreatedBy(), 'updated_date' => $bank_account->getUpdatedDate(), 'updated_by' => $bank_account->getUpdatedBy(), 'deleted_date' => $bank_account->getDeletedDate(), 'deleted_by' => $bank_account->getDeletedBy()); } } if (isset($user_id) and $company_id == '') { //$user_id = $current_user->getId(); $ulf = new UserListFactory(); $full_name = $ulf->getById($user_id)->getCurrent()->getFullName(); } elseif ($company_id != '') { $clf = new CompanyListFactory(); $full_name = $clf->getById($company_id)->getCurrent()->getName(); } $bank_data['full_name'] = $full_name; $bank_data['country'] = strtolower($country); $bank_data['user_id'] = $user_id; $bank_data['company_id'] = $company_id; //var_dump($bank_data); $smarty->assign_by_ref('bank_data', $bank_data); $smarty->assign_by_ref('data_saved', $data_saved); break; } $smarty->assign_by_ref('baf', $baf); //$smarty->assign_by_ref('current_time', TTDate::getDate('TIME') ); $smarty->display('bank_account/EditBankAccount.tpl');
TTi18n::chooseBestLocale(); } else { //Increase timeout on WAP devices, so they don't have to login as often. if (isset($enable_wap) and $enable_wap == TRUE) { $authentication->setIdle(32400); //9hrs } elseif (isset($config_vars['other']['web_session_timeout']) and $config_vars['other']['web_session_timeout'] != '') { $authentication->setIdle((int) $config_vars['other']['web_session_timeout']); } if ($authentication->Check() === TRUE) { /* * Get default interface data here. Things like User info, Company info etc... */ $current_user = $authentication->getObject(); Debug::text('User Authenticated: ' . $current_user->getUserName() . ' Created Date: ' . $authentication->getCreatedDate(), __FILE__, __LINE__, __METHOD__, 10); $clf = new CompanyListFactory(); $current_company = $clf->getByID($current_user->getCompany())->getCurrent(); unset($clf); //Check to make sure the logged in user's information is all up to date. //Make sure they also have permissions to edit information, otherwise don't redirect them. if ($current_user->isInformationComplete() == FALSE and (!stristr($_SERVER['SCRIPT_NAME'], 'permissiondenied') and !stristr($_SERVER['SCRIPT_NAME'], 'logout') and !stristr($_SERVER['SCRIPT_NAME'], 'about') and !stristr($_SERVER['SCRIPT_NAME'], 'punch.php') and !stristr($_SERVER['SCRIPT_NAME'], 'ajax_server') and !stristr($_SERVER['SCRIPT_NAME'], 'global.js') and !stristr($_SERVER['SCRIPT_NAME'], 'menu.js') and !stristr($_SERVER['SCRIPT_NAME'], 'embeddeddocument')) and !isset($_GET['incomplete']) and !isset($_POST['incomplete']) and ($permission->Check('user', 'enabled') and ($permission->Check('user', 'edit') or $permission->Check('user', 'edit_own') or $permission->Check('user', 'edit_child')))) { Redirect::Page(URLBuilder::getURL(array('id' => $current_user->getID(), 'incomplete' => 1), Environment::GetBaseURL() . 'users/EditUser.php')); } $db_time_zone_error = FALSE; $current_user_prefs = $current_user->getUserPreferenceObject(); //If user doesnt have any preferences set, we need to bootstrap the preference object. if ($current_user_prefs->getUser() == '') { $current_user_prefs->setUser($current_user->getId()); } if ($current_user_prefs->setDateTimePreferences() == FALSE) { //Setting timezone failed, alert user to this fact.
//Can Break IE with downloading PDFs over SSL. // IE gets: "file could not be written to cache" // It works on some IE installs though. // Comment out No-Cache and Pragma: No-Cache to fix issue. header('Cache-Control: no-cache'); //Adding FALSE here breaks IE. header('Cache-Control: post-check=0,pre-check=0'); header('Cache-Control: max-age=0'); header('Pragma: public'); } //Do not overwrite a previously sent content-type header, this breaks WAP. if (!isset($enable_wap)) { header('Content-Type: text/html; charset=UTF-8'); } //Skip this step if disable_database_connection is enabled or the user is going through the installer still $clf = new CompanyListFactory(); if ((!isset($disable_database_connection) or isset($disable_database_connection) and $disable_database_connection != TRUE) and (!isset($config_vars['other']['installer_enabled']) or isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] != TRUE)) { //Get all system settings, so they can be used even if the user isn't logged in, such as the login page. try { $sslf = new SystemSettingListFactory(); $system_settings = $sslf->getAllArray(); unset($sslf); //Get primary company data needs to be used when user isn't logged in as well. $clf->getByID(PRIMARY_COMPANY_ID); if ($clf->getRecordCount() == 1) { $primary_company = $clf->getCurrent(); } } catch (Exception $e) { //Database not initialized, or some error, redirect to Install page. throw new DBError($e, 'DBInitialize'); }