function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($this->data, 'Data: ', __FILE__, __LINE__, __METHOD__,10); //$last_row = count($this->form_data)-1; //$total_row = $last_row+1; $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $this->sortFormData(); //Make sure forms are sorted. if ($format == 'efile_xml') { $t619 = $this->getT619Object(); $t619->setStatus($setup_data['status_id']); $t619->transmitter_number = isset($setup_data['transmitter_number']) ? $setup_data['transmitter_number'] : NULL; $t619->transmitter_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $t619->transmitter_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1(); $t619->transmitter_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2(); $t619->transmitter_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $t619->transmitter_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $t619->transmitter_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $t619->contact_name = $this->getUserObject()->getFullName(); $t619->contact_phone = $current_company->getWorkPhone(); $t619->contact_email = $this->getUserObject()->getWorkEmail(); $this->getFormObject()->addForm($t619); } $t4 = $this->getT4Object(); if (isset($setup_data['include_t4_back']) and $setup_data['include_t4_back'] == 1) { $t4->setShowInstructionPage(TRUE); } if (stristr($format, 'government')) { $form_type = 'government'; } else { $form_type = 'employee'; } Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10); $t4->setType($form_type); $t4->setStatus($setup_data['status_id']); $t4->year = TTDate::getYear($filter_data['start_date']); $t4->payroll_account_number = (isset($setup_data['payroll_account_number']) and $setup_data['payroll_account_number'] != '') ? $setup_data['payroll_account_number'] : $current_company->getBusinessNumber(); $t4->company_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $i = 0; if (is_array($this->form_data)) { foreach ($this->form_data as $row) { //if ( $i == $last_row ) { // continue; //} if (!isset($row['user_id'])) { Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10); continue; } $ulf = TTnew('UserListFactory'); $ulf->getById((int) $row['user_id']); if ($ulf->getRecordCount() == 1) { $user_obj = $ulf->getCurrent(); $ee_data = array('first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'province' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'postal_code' => $user_obj->getPostalCode(), 'sin' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l14' => $row['income'], 'l22' => $row['tax'], 'l16' => $row['employee_cpp'], 'l24' => $row['ei_earnings'], 'l26' => $row['cpp_earnings'], 'l18' => $row['employee_ei'], 'l44' => $row['union_dues'], 'l20' => $row['rpp'], 'l46' => $row['charity'], 'l52' => $row['pension_adjustment'], 'l50' => $setup_data['rpp_number'], 'cpp_exempt' => FALSE, 'ei_exempt' => FALSE, 'other_box_0_code' => NULL, 'other_box_0' => NULL, 'other_box_1_code' => NULL, 'other_box_1' => NULL, 'other_box_2_code' => NULL, 'other_box_2' => NULL, 'other_box_3_code' => NULL, 'other_box_3' => NULL, 'other_box_4_code' => NULL, 'other_box_4' => NULL, 'other_box_5_code' => NULL, 'other_box_5' => NULL); //Get User Tax / Deductions by Pay Stub Account. $udlf = TTnew('UserDeductionListFactory'); if (isset($setup_data['employee_cpp']['include_pay_stub_entry_account'])) { $udlf->getByUserIdAndPayStubEntryAccountID($user_obj->getId(), $setup_data['employee_cpp']['include_pay_stub_entry_account']); //FIXME: What if they were CPP exempt because of age, so no CPP was taken off, but they are assigned to the Tax/Deduction? //Don't think there is much we can do about this for now. if ($setup_data['employee_cpp']['include_pay_stub_entry_account'] != 0 and $udlf->getRecordCount() == 0 and $row['employee_cpp'] == 0) { //Debug::Text('CPP Exempt!', __FILE__, __LINE__, __METHOD__,10); $ee_data['cpp_exempt'] = TRUE; } } if (isset($setup_data['employee_ei']['include_pay_stub_entry_account'])) { $udlf->getByUserIdAndPayStubEntryAccountID($user_obj->getId(), $setup_data['employee_ei']['include_pay_stub_entry_account']); if ($setup_data['employee_ei']['include_pay_stub_entry_account'] != 0 and $udlf->getRecordCount() == 0 and $row['employee_ei'] == 0) { //Debug::Text('EI Exempt!', __FILE__, __LINE__, __METHOD__,10); $ee_data['ei_exempt'] = TRUE; } } if ($row['other_box_0'] > 0 and isset($setup_data['other_box'][0]['box']) and $setup_data['other_box'][0]['box'] != '') { $ee_data['other_box_0_code'] = $setup_data['other_box'][0]['box']; $ee_data['other_box_0'] = $row['other_box_0']; } if ($row['other_box_1'] > 0 and isset($setup_data['other_box'][1]['box']) and $setup_data['other_box'][1]['box'] != '') { $ee_data['other_box_1_code'] = $setup_data['other_box'][1]['box']; $ee_data['other_box_1'] = $row['other_box_1']; } if ($row['other_box_2'] > 0 and isset($setup_data['other_box'][2]['box']) and $setup_data['other_box'][2]['box'] != '') { $ee_data['other_box_2_code'] = $setup_data['other_box'][2]['box']; $ee_data['other_box_2'] = $row['other_box_2']; } if ($row['other_box_3'] > 0 and isset($setup_data['other_box'][3]['box']) and $setup_data['other_box'][3]['box'] != '') { $ee_data['other_box_3_code'] = $setup_data['other_box'][3]['box']; $ee_data['other_box_3'] = $row['other_box_3']; } if ($row['other_box_4'] > 0 and isset($setup_data['other_box'][4]['box']) and $setup_data['other_box'][4]['box'] != '') { $ee_data['other_box_4_code'] = $setup_data['other_box'][4]['box']; $ee_data['other_box_4'] = $row['other_box_4']; } if ($row['other_box_5'] > 0 and isset($setup_data['other_box'][5]['box']) and $setup_data['other_box'][5]['box'] != '') { $ee_data['other_box_5_code'] = $setup_data['other_box'][5]['box']; $ee_data['other_box_5'] = $row['other_box_5']; } $t4->addRecord($ee_data); unset($ee_data); $i++; } } $this->getFormObject()->addForm($t4); } //Handle T4Summary $t4s = $this->getT4SumObject(); $t4s->setStatus($setup_data['status_id']); $t4s->year = $t4->year; $t4s->payroll_account_number = $t4->payroll_account_number; $t4s->company_name = $t4->company_name; $t4s->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1(); $t4s->company_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2(); $t4s->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $t4s->company_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $t4s->company_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $t4s->l76 = $this->getUserObject()->getFullName(); //Contact name. $t4s->l78 = $current_company->getWorkPhone(); $total_row = Misc::ArrayAssocSum($this->form_data); $t4s->l88 = count($this->form_data); $t4s->l14 = $total_row['income']; $t4s->l22 = $total_row['tax']; $t4s->l16 = $total_row['employee_cpp']; $t4s->l18 = $total_row['employee_ei']; $t4s->l27 = $total_row['employer_cpp']; $t4s->l19 = $total_row['employer_ei']; $t4s->l20 = $total_row['rpp']; $t4s->l52 = $total_row['pension_adjustment']; $total_deductions = Misc::MoneyFormat(Misc::sumMultipleColumns($total_row, array('tax', 'employee_cpp', 'employee_ei', 'employer_cpp', 'employer_ei')), FALSE); $t4s->l82 = $total_deductions; $this->getFormObject()->addForm($t4s); if ($format == 'efile_xml') { $output_format = 'XML'; $file_name = 't4_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name . '.pdf'; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); if (!is_array($output)) { return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $output); } return $output; }
function loadPreviousPayStub() { if ($this->getUser() == FALSE or $this->getStartDate() == FALSE) { return FALSE; } //Grab last pay stub so we can use it for YTD calculations on this pay stub. $pslf = new PayStubListFactory(); $pslf->getLastPayStubByUserIdAndStartDate($this->getUser(), $this->getStartDate()); if ($pslf->getRecordCount() > 0) { $ps_obj = $pslf->getCurrent(); Debug::text('Loading Data from Pay Stub ID: ' . $ps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); $retarr = array('id' => $ps_obj->getId(), 'start_date' => $ps_obj->getStartDate(), 'end_date' => $ps_obj->getEndDate(), 'transaction_date' => $ps_obj->getTransactionDate(), 'entries' => NULL); // //If previous pay stub is in a different year, only carry forward the accrual accounts. // $new_year = FALSE; if (TTDate::getYear($this->getTransactionDate()) != TTDate::getYear($ps_obj->getTransactionDate())) { Debug::text('Pay Stub Years dont match!...', __FILE__, __LINE__, __METHOD__, 10); $new_year = TRUE; } //Get pay stub entries $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($ps_obj->getID()); if ($pself->getRecordCount() > 0) { foreach ($pself as $pse_obj) { //Get PSE account type, group by that. $psea_arr = $this->getPayStubEntryAccountArray($pse_obj->getPayStubEntryNameId()); if (is_array($psea_arr)) { $type_id = $psea_arr['type_id']; } else { $type_id = NULL; } //If we're just starting a new year, only carry over //accrual balances, reset all YTD entries. if ($new_year == FALSE or $type_id == 50) { $pse_arr[] = array('id' => $pse_obj->getId(), 'pay_stub_entry_type_id' => $type_id, 'pay_stub_entry_account_id' => $pse_obj->getPayStubEntryNameId(), 'pay_stub_amendment_id' => $pse_obj->getPayStubAmendment(), 'rate' => $pse_obj->getRate(), 'units' => $pse_obj->getUnits(), 'amount' => $pse_obj->getAmount(), 'ytd_units' => $pse_obj->getYTDUnits(), 'ytd_amount' => $pse_obj->getYTDAmount()); } unset($type_id, $psea_obj); } if (isset($pse_arr)) { $retarr['entries'] = $pse_arr; $this->tmp_data['previous_pay_stub'] = $retarr; return TRUE; } } } Debug::text('Returning FALSE...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government' or $format == 'efile') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $current_user = $this->getUserObject(); if (!is_object($current_user)) { Debug::Text('Invalid user object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if ($format == 'efile_xml') { $return1040 = $this->getRETURN1040Object(); // Ceate the all needed data for Return1040.xsd at here. $return1040->return_created_timestamp = TTDate::getDBTimeStamp(TTDate::getTime(), FALSE); $return1040->year = TTDate::getYear($filter_data['end_date']); $return1040->tax_period_begin_date = TTDate::getDate('Y-m-d', TTDate::getBeginDayEpoch($filter_data['start_date'])); $return1040->tax_period_end__date = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date'])); $return1040->software_id = ''; $return1040->originator_efin = ''; $return1040->originator_type_code = ''; $return1040->pin_type_code = ''; $return1040->jurat_disclosure_code = ''; $return1040->pin_entered_by = ''; $return1040->signature_date = TTDate::getDate('Y-m-d', TTDate::getTime()); $return1040->return_type = ''; $return1040->ssn = ''; $return1040->name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $return1040->name_control = ''; $return1040->address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $return1040->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $return1040->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $return1040->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $return1040->ip_address = ''; $return1040->ip_date = TTDate::getDate('Y-m-d', TTDate::getTime()); $return1040->ip_time = TTDate::getDate('H:i:s', TTDate::getTime()); $return1040->timezone = TTDate::getTimeZone(); $this->getFormObject()->addForm($return1040); } $this->sortFormData(); //Make sure forms are sorted. $fw2 = $this->getFW2Object(); $fw2->setDebug(FALSE); //if ( $format == 'efile' ) { // $fw2->setDebug(TRUE); //} $fw2->setShowBackground($show_background); if (stristr($format, 'government')) { $form_type = 'government'; } else { $form_type = 'employee'; } Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10); $fw2->setType($form_type); $fw2->year = TTDate::getYear($filter_data['end_date']); //Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually. $fw2->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $fw2->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName(); $fw2->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $fw2->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $fw2->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $fw2->company_state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $fw2->company_zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $fw2->efile_user_id = (isset($setup_data['efile_user_id']) and $setup_data['efile_user_id'] != '') ? $setup_data['efile_user_id'] : NULL; $fw2->efile_state = (isset($setup_data['efile_state']) and $setup_data['efile_state'] != '') ? $setup_data['efile_state'] : 0; $fw2->contact_name = $current_user->getFullName(); $fw2->contact_phone = $current_user->getWorkPhone(); $fw2->contact_phone_ext = $current_user->getWorkPhoneExt(); $fw2->contact_email = $current_user->getWorkEmail(); if (isset($this->form_data) and count($this->form_data) > 0) { $i = 0; $n = 1; foreach ((array) $this->form_data as $row) { if (!isset($row['user_id'])) { Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10); continue; } $ulf = TTnew('UserListFactory'); $ulf->getById((int) $row['user_id']); if ($ulf->getRecordCount() == 1) { $user_obj = $ulf->getCurrent(); $ee_data = array('control_number' => $n, 'first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'state' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'zip_code' => $user_obj->getPostalCode(), 'ssn' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l1' => $row['l1'], 'l2' => $row['l2'], 'l3' => $row['l3'], 'l4' => $row['l4'], 'l5' => $row['l5'], 'l6' => $row['l6'], 'l7' => $row['l7'], 'l8' => $row['l8'], 'l10' => $row['l10'], 'l11' => $row['l11'], 'l12a_code' => NULL, 'l12a' => NULL, 'l12b_code' => NULL, 'l12b' => NULL, 'l12c_code' => NULL, 'l12c' => NULL, 'l12d_code' => NULL, 'l12d' => NULL, 'l14a_name' => NULL, 'l14a' => NULL, 'l14b_name' => NULL, 'l14b' => NULL, 'l14c_name' => NULL, 'l14c' => NULL, 'l14d_name' => NULL, 'l14d' => NULL); if ($row['l12a'] > 0 and isset($setup_data['l12a_code']) and $setup_data['l12a_code'] != '') { $ee_data['l12a_code'] = $setup_data['l12a_code']; $ee_data['l12a'] = $row['l12a']; } if ($row['l12b'] > 0 and isset($setup_data['l12b_code']) and $setup_data['l12b_code'] != '') { $ee_data['l12b_code'] = $setup_data['l12b_code']; $ee_data['l12b'] = $row['l12b']; } if ($row['l12c'] > 0 and isset($setup_data['l12c_code']) and $setup_data['l12c_code'] != '') { $ee_data['l12c_code'] = $setup_data['l12c_code']; $ee_data['l12c'] = $row['l12c']; } if ($row['l12d'] > 0 and isset($setup_data['l12d_code']) and $setup_data['l12d_code'] != '') { $ee_data['l12d_code'] = $setup_data['l12d_code']; $ee_data['l12d'] = $row['l12d']; } if ($row['l14a'] > 0 and isset($setup_data['l14a_name']) and $setup_data['l14a_name'] != '') { $ee_data['l14a_name'] = $setup_data['l14a_name']; $ee_data['l14a'] = $row['l14a']; } if ($row['l14b'] > 0 and isset($setup_data['l14b_name']) and $setup_data['l14b_name'] != '') { $ee_data['l14b_name'] = $setup_data['l14b_name']; $ee_data['l14b'] = $row['l14b']; } if ($row['l14c'] > 0 and isset($setup_data['l14c_name']) and $setup_data['l14c_name'] != '') { $ee_data['l14c_name'] = $setup_data['l14c_name']; $ee_data['l14c'] = $row['l14c']; } if ($row['l14d'] > 0 and isset($setup_data['l14d_name']) and $setup_data['l14d_name'] != '') { $ee_data['l14d_name'] = $setup_data['l14d_name']; $ee_data['l14d'] = $row['l14d']; } foreach (range('a', 'z') as $z) { //State income tax if (isset($row['l16' . $z])) { if (isset($setup_data['state'][$row['l15' . $z . '_state']])) { $ee_data['l15' . $z . '_state_id'] = $setup_data['state'][$row['l15' . $z . '_state']]['state_id']; } $ee_data['l15' . $z . '_state'] = $row['l15' . $z . '_state']; $ee_data['l16' . $z] = $row['l16' . $z]; $ee_data['l17' . $z] = $row['l17' . $z]; } else { $ee_data['l15' . $z . '_state_id'] = NULL; $ee_data['l15' . $z . '_state'] = NULL; $ee_data['l16' . $z] = NULL; $ee_data['l17' . $z] = NULL; } //District income tax if (isset($row['l18' . $z])) { $ee_data['l18' . $z] = $row['l18' . $z]; $ee_data['l19' . $z] = $row['l19' . $z]; $ee_data['l20' . $z] = $row['l20' . $z]; } else { $ee_data['l18' . $z] = NULL; $ee_data['l19' . $z] = NULL; $ee_data['l20' . $z] = NULL; } } $fw2->addRecord($ee_data); unset($ee_data); $i++; $n++; } } } $this->getFormObject()->addForm($fw2); if ($form_type == 'government') { //Handle W3 $fw3 = $this->getFW3Object(); $fw3->setShowBackground($show_background); $fw3->year = $fw2->year; $fw3->ein = $fw2->ein; $fw3->name = $fw2->name; $fw3->trade_name = $fw2->trade_name; $fw3->company_address1 = $fw2->company_address1; $fw3->company_address2 = $fw2->company_address2; $fw3->company_city = $fw2->company_city; $fw3->company_state = $fw2->company_state; $fw3->company_zip_code = $fw2->company_zip_code; $fw3->contact_name = $current_user->getFullName(); $fw3->contact_phone = $current_user->getWorkPhoneExt() != '' ? $current_user->getWorkPhone() . 'x' . $current_user->getWorkPhoneExt() : $current_user->getWorkPhone(); $fw3->contact_email = $current_user->getWorkEmail(); $fw3->kind_of_payer = '941'; $fw3->kind_of_employer = 'none'; //$fw3->third_party_sick_pay = TRUE; if (isset($setup_data['state'][$fw2->company_state]) and isset($setup_data['state'][$fw2->company_state]['state_id']) and $setup_data['state'][$fw2->company_state]['state_id'] != '') { $fw3->state_id1 = $setup_data['state'][$fw2->company_state]['state_id']; } $fw3->lc = count($this->form_data); $fw3->control_number = $fw3->lc + 1; //$fw3->ld = '1234568'; $total_row = Misc::ArrayAssocSum($this->form_data); //Debug::Arr($total_row, 'Total Row Data: ', __FILE__, __LINE__, __METHOD__,10); if (is_array($total_row)) { $fw3->l1 = $total_row['l1']; $fw3->l2 = $total_row['l2']; $fw3->l3 = $total_row['l3']; $fw3->l4 = $total_row['l4']; $fw3->l5 = $total_row['l5']; $fw3->l6 = $total_row['l6']; $fw3->l7 = $total_row['l7']; $fw3->l8 = $total_row['l8']; $fw3->l10 = $total_row['l10']; $fw3->l11 = $total_row['l11']; foreach (range('a', 'z') as $z) { //State income tax if (isset($total_row['l16' . $z])) { $fw3->l16 += $total_row['l16' . $z]; $fw3->l17 += $total_row['l17' . $z]; } //District income tax if (isset($total_row['l18' . $z])) { $fw3->l18 += $total_row['l18' . $z]; $fw3->l19 += $total_row['l19' . $z]; } } } $this->getFormObject()->addForm($fw3); } if ($format == 'efile') { $output_format = 'EFILE'; if ($fw2->getDebug() == TRUE) { $file_name = 'w2_efile_' . date('Y_m_d') . '.csv'; } else { $file_name = 'w2_efile_' . date('Y_m_d') . '.txt'; } $mime_type = 'applications/octet-stream'; //Force file to download. } elseif ($format == 'efile_xml') { $output_format = 'XML'; $file_name = 'w2_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $output); }
function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($this->data, 'Data: ', __FILE__, __LINE__, __METHOD__,10); //$last_row = count($this->form_data)-1; //$total_row = $last_row+1; $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $this->sortFormData(); //Make sure forms are sorted. if ($format == 'efile_xml') { $t619 = $this->getT619Object(); $t619->setStatus($setup_data['status_id']); $t619->transmitter_number = isset($setup_data['transmitter_number']) ? $setup_data['transmitter_number'] : NULL; $t619->transmitter_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $t619->transmitter_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1(); $t619->transmitter_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2(); $t619->transmitter_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $t619->transmitter_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $t619->transmitter_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $t619->contact_name = $this->getUserObject()->getFullName(); $t619->contact_phone = $current_company->getWorkPhone(); $t619->contact_email = $this->getUserObject()->getWorkEmail(); $this->getFormObject()->addForm($t619); } $t4a = $this->getT4AObject(); if (isset($setup_data['include_t4a_back']) and $setup_data['include_t4a_back'] == 1) { $t4a->setShowInstructionPage(TRUE); } if (stristr($format, 'government')) { $form_type = 'government'; } else { $form_type = 'employee'; } Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10); $t4a->setType($form_type); $t4a->setStatus($setup_data['status_id']); $t4a->year = TTDate::getYear($filter_data['start_date']); $t4a->payroll_account_number = (isset($setup_data['payroll_account_number']) and $setup_data['payroll_account_number'] != '') ? $setup_data['payroll_account_number'] : $current_company->getBusinessNumber(); $t4a->company_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $i = 0; foreach ($this->form_data as $row) { //if ( $i == $last_row ) { // continue; //} if (!isset($row['user_id'])) { Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10); continue; } $ulf = TTnew('UserListFactory'); $ulf->getById((int) $row['user_id']); if ($ulf->getRecordCount() == 1) { $user_obj = $ulf->getCurrent(); $ee_data = array('first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'province' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'postal_code' => $user_obj->getPostalCode(), 'sin' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l16' => $row['pension'], 'l22' => $row['income_tax'], 'l18' => $row['lump_sum_payment'], 'l20' => $row['self_employed_commission'], 'l24' => $row['annuities'], 'l48' => $row['service_fees'], 'other_box_0_code' => NULL, 'other_box_0' => NULL, 'other_box_1_code' => NULL, 'other_box_1' => NULL, 'other_box_2_code' => NULL, 'other_box_2' => NULL, 'other_box_3_code' => NULL, 'other_box_3' => NULL, 'other_box_4_code' => NULL, 'other_box_4' => NULL, 'other_box_5_code' => NULL, 'other_box_5' => NULL); if ($row['other_box_0'] > 0 and isset($setup_data['other_box'][0]['box']) and $setup_data['other_box'][0]['box'] != '') { $ee_data['other_box_0_code'] = $setup_data['other_box'][0]['box']; $ee_data['other_box_0'] = $row['other_box_0']; } if ($row['other_box_1'] > 0 and isset($setup_data['other_box'][1]['box']) and $setup_data['other_box'][1]['box'] != '') { $ee_data['other_box_1_code'] = $setup_data['other_box'][1]['box']; $ee_data['other_box_1'] = $row['other_box_1']; } if ($row['other_box_2'] > 0 and isset($setup_data['other_box'][2]['box']) and $setup_data['other_box'][2]['box'] != '') { $ee_data['other_box_2_code'] = $setup_data['other_box'][2]['box']; $ee_data['other_box_2'] = $row['other_box_2']; } if ($row['other_box_3'] > 0 and isset($setup_data['other_box'][3]['box']) and $setup_data['other_box'][3]['box'] != '') { $ee_data['other_box_3_code'] = $setup_data['other_box'][3]['box']; $ee_data['other_box_3'] = $row['other_box_3']; } if ($row['other_box_4'] > 0 and isset($setup_data['other_box'][4]['box']) and $setup_data['other_box'][4]['box'] != '') { $ee_data['other_box_4_code'] = $setup_data['other_box'][4]['box']; $ee_data['other_box_4'] = $row['other_box_4']; } $t4a->addRecord($ee_data); unset($ee_data); $i++; } } $this->getFormObject()->addForm($t4a); //Handle T4ASummary $t4as = $this->getT4ASumObject(); $t4as->setStatus($setup_data['status_id']); $t4as->year = $t4a->year; $t4as->payroll_account_number = $t4a->payroll_account_number; $t4as->company_name = $t4a->company_name; $t4as->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1(); $t4as->company_address2 = (isset($setup_data['address2']) and $setup_data['address2'] != '') ? $setup_data['address2'] : $current_company->getAddress2(); $t4as->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $t4as->company_province = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $t4as->company_postal_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $t4as->l76 = $this->getUserObject()->getFullName(); //Contact name. $t4as->l78 = $current_company->getWorkPhone(); $total_row = Misc::ArrayAssocSum($this->form_data); $t4as->l88 = count($this->form_data); $t4as->l16 = $total_row['pension']; $t4as->l22 = $total_row['income_tax']; $t4as->l18 = $total_row['lump_sum_payment']; $t4as->l20 = $total_row['self_employed_commission']; $t4as->l24 = $total_row['annuities']; $t4as->l48 = $total_row['service_fees']; if (isset($setup_data['other_box'])) { foreach ($setup_data['other_box'] as $key => $other_box_data) { //Debug::Text('zFound other box total for T4A Sum: '. $key .' Code: '. $other_box_data['box'], __FILE__, __LINE__, __METHOD__,10); if (in_array((int) $other_box_data['box'], array(28, 30, 32, 34, 40, 42))) { //Debug::Text('Found other box total for T4A Sum: '. $key .' Code: '. $other_box_data['box'], __FILE__, __LINE__, __METHOD__,10); $object_var = 'l' . (int) $other_box_data['box']; $t4as->{$object_var} = $total_row['other_box_' . $key]; unset($object_var); } } } unset($other_box_data, $key); $total_other_deductions = Misc::MoneyFormat(Misc::sumMultipleColumns($total_row, array('other_box_0', 'other_box_1', 'other_box_2', 'other_box_3', 'other_box_4')), FALSE); $t4as->l101 = $total_other_deductions; //$total_deductions = Misc::MoneyFormat( Misc::sumMultipleColumns( $total_row, array('pension','income_tax','lump_sum_payment', 'self_employed_commission', 'annuities','service_fees') ), FALSE ); //$t4as->l82 = $total_deductions; $t4as->l82 = $total_row['income_tax']; $this->getFormObject()->addForm($t4as); if ($format == 'efile_xml') { $output_format = 'XML'; $file_name = 't4a_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $output); }
function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if ($format == 'efile_xml') { $return940 = $this->getRETURN940Object(); $return940->TaxPeriodEndDate = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date'])); $return940->ReturnType = ''; $return940->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $return940->BusinessName1 = ''; $return940->BusinessNameControl = ''; $return940->AddressLine = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $return940->City = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $return940->State = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $return940->ZIPCode = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $this->getFormObject()->addForm($return940); } $f940 = $this->getF940Object(); $f940->setDebug(FALSE); $f940->setShowBackground($show_background); $f940->year = TTDate::getYear($filter_data['end_date']); //Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually. $f940->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $f940->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName(); $f940->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $f940->address = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $f940->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $f940->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $f940->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); if (isset($setup_data['return_type']) and is_array($setup_data['return_type'])) { $return_type_arr = array(); foreach ($setup_data['return_type'] as $return_type) { switch ($return_type) { case 10: //Amended $return_type_arr[] = 'a'; break; case 20: //Successor $return_type_arr[] = 'b'; break; case 30: //No Payments $return_type_arr[] = 'c'; break; case 40: //Final $return_type_arr[] = 'd'; break; } } $f940->return_type = $return_type_arr; } if (isset($setup_data['state_id'])) { if ($setup_data['state_id'] === 0 or $setup_data['state_id'] == '00' or $setup_data['state_id'] == '') { $f940->l1b = TRUE; //Let them set this manually. } else { if (strlen($setup_data['state_id']) == 2) { $f940->l1a = $setup_data['state_id']; } } } //Exempt payment check boxes if (isset($setup_data['exempt_payment']) and is_array($setup_data['exempt_payment'])) { foreach ($setup_data['exempt_payment'] as $return_type) { switch ($return_type) { case 10: //Fringe $f940->l4a = TRUE; break; case 20: //Group life insurance $f940->l4b = TRUE; break; case 30: //Retirement/Pension $f940->l4c = TRUE; break; case 40: //Dependant care $f940->l4d = TRUE; break; case 50: //Other $f940->l4e = TRUE; break; } } } //Debug::Arr($this->form_data['quarter'], 'Final Data for Form: ', __FILE__, __LINE__, __METHOD__,10); if (isset($this->form_data) and count($this->form_data) == 3) { $f940->l3 = $this->form_data['total']['total_payments']; $f940->l4 = $this->form_data['total']['exempt_payments']; $f940->l5 = $this->form_data['total']['excess_payments']; $f940->l10 = $setup_data['line_10']; $f940->l11 = $setup_data['line_11']; $f940->l13 = $setup_data['tax_deposited']; $f940->l15b = TRUE; if (isset($this->form_data['quarter'][1]['after_adjustment_tax'])) { $f940->l16a = $this->form_data['quarter'][1]['after_adjustment_tax']; } if (isset($this->form_data['quarter'][2]['after_adjustment_tax'])) { $f940->l16b = $this->form_data['quarter'][2]['after_adjustment_tax']; } if (isset($this->form_data['quarter'][3]['after_adjustment_tax'])) { $f940->l16c = $this->form_data['quarter'][3]['after_adjustment_tax']; } if (isset($this->form_data['quarter'][4]['after_adjustment_tax'])) { $f940->l16d = $this->form_data['quarter'][4]['after_adjustment_tax']; } } else { Debug::Arr($this->data, 'Invalid Form Data: ', __FILE__, __LINE__, __METHOD__, 10); } $this->getFormObject()->addForm($f940); if (isset($f940sb) and is_object($f940sb)) { $this->getFormObject()->addForm($f940sb); } if ($format == 'efile_xml') { $output_format = 'XML'; $file_name = '940_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); return $output; }
function createUser($company_id, $type, $policy_group_id = 0, $default_branch_id = 0, $default_department_id = 0, $default_currency_id = 0, $user_group_id = 0, $user_title_id = 0, $ethnic_group_ids = NULL) { $uf = TTnew('UserFactory'); $uf->setCompany($company_id); $uf->setStatus(10); //$uf->setPolicyGroup( 0 ); if ($default_currency_id == 0) { Debug::Text('Get Default Currency...', __FILE__, __LINE__, __METHOD__, 10); //Get Default. $crlf = TTnew('CurrencyListFactory'); $crlf->getByCompanyIdAndDefault($company_id, TRUE); if ($crlf->getRecordCount() > 0) { $default_currency_id = $crlf->getCurrent()->getId(); Debug::Text('Default Currency ID: ' . $default_currency_id, __FILE__, __LINE__, __METHOD__, 10); } } srand($type); //Seed the random number the same for each createUser() call of the same type, so unit tests can rely on a constant hire date/employee wage. $hire_date = strtotime(rand(TTDate::getYear() - 10, TTDate::getYear() - 2) . '-' . rand(1, 12) . '-' . rand(1, 28)); if (empty($ethnic_group_ids) == FALSE) { $uf->setEthnicGroup($this->getRandomArrayValue((array) $ethnic_group_ids)); } switch ($type) { case 10: //John Doe $uf->setUserName('john.doe' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('John'); $uf->setLastName('Doe'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Springfield St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 11: //Theodora Simmons $uf->setUserName('theodora.simmons' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Theodora'); $uf->setLastName('Simmons'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Springfield St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 12: //Kitty Nicholas $uf->setUserName('kitty.nicholas' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Kitty'); $uf->setLastName('Nicholas'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Ethel St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 13: //Tristen Braun $uf->setUserName('tristen.braun' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Tristen'); $uf->setLastName('Braun'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Ethel St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 14: //Gale Mench $uf->setUserName('gale.mench' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Gale'); $uf->setLastName('Mench'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Gordon St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 15: //Beau Mayers $uf->setUserName('beau.mayers' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Beau'); $uf->setLastName('Mayers'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Gordon St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 16: //Ian Schofield $uf->setUserName('ian.schofield' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Ian'); $uf->setLastName('Schofield'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Sussex St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 17: //Gabe Hoffhants $uf->setUserName('gabe.hoffhants' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Gabe'); $uf->setLastName('Hoffhants'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Sussex St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 18: //Franklin Mcmichaels $uf->setUserName('franklin.mcmichaels' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Franklin'); $uf->setLastName('McMichaels'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Georgia St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 19: //Donald Whitling $uf->setUserName('donald.whitling' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Donald'); $uf->setLastName('Whitling'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Georgia St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 20: //Jane Doe $uf->setUserName('jane.doe' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '2222' ); //$uf->setPhonePassword( '2222' ); $uf->setFirstName('Jane'); $uf->setLastName('Doe'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Ontario St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 21: //Tamera Erschoff $uf->setUserName('tamera.erschoff' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Tamera'); $uf->setLastName('Erschoff'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Ontario St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 22: //Redd Rifler $uf->setUserName('redd.rifler' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Redd'); $uf->setLastName('Rifler'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Main St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 23: //Brent Pawle $uf->setUserName('brent.pawle' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Brent'); $uf->setLastName('Pawle'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Pandosy St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 24: //Heather Grant $uf->setUserName('heather.grant' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Heather'); $uf->setLastName('Grant'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Lakeshore St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 25: //Steph Mench $uf->setUserName('steph.mench' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Steph'); $uf->setLastName('Mench'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Dobbin St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 26: //Kailey Klockman $uf->setUserName('kailey.klockman' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Kailey'); $uf->setLastName('Klockman'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Spall St'); //$uf->setAddress2( 'Unit #123' ); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 27: //Matt Marcotte $uf->setUserName('matt.marcotte' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Matt'); $uf->setLastName('Marcotte'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Spall St'); //$uf->setAddress2( 'Unit #123' ); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 28: //Nick Hanseu $uf->setUserName('nick.hanseu' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Nick'); $uf->setLastName('Hanseu'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Gates St'); //$uf->setAddress2( 'Unit #123' ); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 29: //Rich Wiggins $uf->setUserName('rich.wiggins' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '1111' ); //$uf->setPhonePassword( '1111' ); $uf->setFirstName('Rich'); $uf->setLastName('Wiggins'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Gates St'); //$uf->setAddress2( 'Unit #123' ); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 30: //Mike Smith $uf->setUserName('mike.smith' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '2222' ); //$uf->setPhonePassword( '2222' ); $uf->setFirstName('Mike'); $uf->setLastName('Smith'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Main St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 40: //John Hancock $uf->setUserName('john.hancock' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //Set Phone ID/Password to test web quickpunch if ($this->getEnableQuickPunch() == TRUE) { $uf->setPhoneId('1234' . $this->getUserNamePostfix()); $uf->setPhonePassword('1234'); } $uf->setFirstName('John'); $uf->setLastName('Hancock'); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' Main St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('Seattle'); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 100: //Administrator $hire_date = strtotime('01-Jan-2001'); //Force consistent hire date for the administrator, so other unit tests can rely on it. $uf->setUserName('demoadmin' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //Set Phone ID/Password to test web quickpunch if ($this->getEnableQuickPunch() == TRUE) { $uf->setPhoneId('1' . $this->getUserNamePostfix() . '34'); $uf->setPhonePassword('1234'); } $uf->setFirstName('Mr.'); $uf->setLastName('Administrator'); $uf->setSex(10); $uf->setAddress1(rand(100, 9999) . ' Main St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity('New York'); $uf->setCountry('US'); $uf->setProvince('NY'); $uf->setPostalCode(str_pad(rand(400, 599), 5, 0, STR_PAD_LEFT)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber($type); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); break; case 999: //Random user $first_name = $this->getRandomFirstName(); $last_name = $this->getRandomLastName(); if ($first_name != '' and $last_name != '') { $uf->setUserName($first_name . '.' . $last_name . $this->getUserNamePostfix()); $uf->setPassword('demo'); $uf->setFirstName($first_name); $uf->setLastName($last_name); $uf->setSex(20); $uf->setAddress1(rand(100, 9999) . ' ' . $this->getRandomLastName() . ' St'); $uf->setAddress2('Unit #' . rand(10, 999)); $uf->setCity($this->getRandomArrayValue($this->city_names)); $uf->setCountry('US'); $uf->setProvince('WA'); $uf->setPostalCode(rand(98000, 99499)); $uf->setWorkPhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkPhoneExt(rand(100, 1000)); $uf->setHomePhone(rand(403, 600) . '-' . rand(250, 600) . '-' . rand(1000, 9999)); $uf->setWorkEmail($uf->getUserName() . '@abc-company.com'); $uf->setSIN(rand(100, 999) . '-' . rand(100, 999) . '-' . rand(100, 999)); $uf->setBirthDate(strtotime(rand(1970, 1990) . '-' . rand(1, 12) . '-' . rand(1, 28))); $uf->setHireDate($hire_date); $uf->setEmployeeNumber(rand(1000, 25000)); $uf->setDefaultBranch($default_branch_id); $uf->setDefaultDepartment($default_department_id); $uf->setCurrency($default_currency_id); $uf->setGroup($user_group_id); $uf->setTitle($user_title_id); } unset($first_name, $last_name); break; } if ($uf->isValid()) { $insert_id = $uf->Save(); Debug::Text('User ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); $this->createUserPreference($insert_id); /* $preset_flags = array( 'invoice' => 0, 'job' => 1, 'document' => 0, ); */ if ($type == 100) { //$this->createUserPermission( array( $insert_id ), 40, $preset_flags ); $this->createUserPermission($insert_id, 40); } elseif ($type == 10 or $type == 11 or $type == 999) { $this->createUserPermission($insert_id, 18); } else { //$this->createUserPermission( array( $insert_id ), 10, $preset_flags ); $this->createUserPermission($insert_id, 10); } //$this->createUserPermission( array( -1 ), 10, $preset_flags ); //Default wage group $this->createUserWage($insert_id, '19.50', $hire_date); $this->createUserWage($insert_id, '19.75', $hire_date + 86400 * 30 * 6); $this->createUserWage($insert_id, '20.15', $hire_date + 86400 * 30 * 12); $this->createUserWage($insert_id, '21.50', $hire_date + 86400 * 30 * 18); $this->createUserWage($insert_id, '10.00', $hire_date, $this->user_wage_groups[0]); $this->createUserWage($insert_id, '20.00', $hire_date, $this->user_wage_groups[1]); //Assign Taxes to user $this->createUserDeduction($company_id, $insert_id); return $insert_id; } Debug::Text('Failed Creating User!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
function _outputPayrollExport($format = NULL) { $setup_data = $this->getFormConfig(); Debug::Text('Generating Payroll Export... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); if (isset($setup_data['export_type'])) { Debug::Text('Export Type: ' . $setup_data['export_type'], __FILE__, __LINE__, __METHOD__, 10); } else { Debug::Text('No Export Type defined!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } Debug::Arr($setup_data, 'Setup Data: ', __FILE__, __LINE__, __METHOD__, 10); $rows = $this->data; //Debug::Arr($rows, 'PreData: ', __FILE__, __LINE__, __METHOD__,10); $file_name = strtolower(trim($setup_data['export_type'])) . '_' . date('Y_m_d') . '.txt'; $mime_type = 'application/text'; $data = NULL; switch (strtolower(trim($setup_data['export_type']))) { case 'adp': //ADP export format. //File format supports multiple rows per employee (file #) all using the same columns. No need to jump through nasty hoops to fit everything on row. $export_column_map = array('company_code' => 'Co Code', 'batch_id' => 'Batch ID', 'temp_dept' => 'Temp Dept', 'employee_number' => 'File #', 'regular_time' => 'Reg Hours', 'overtime' => 'O/T Hours', '3_code' => 'Hours 3 Code', '3_amount' => 'Hours 3 Amount', '4_code' => 'Hours 4 Code', '4_amount' => 'Hours 4 Amount'); ksort($setup_data['adp']['columns']); $setup_data['adp']['columns'] = Misc::trimSortPrefix($setup_data['adp']['columns']); foreach ($setup_data['adp']['columns'] as $column_id => $column_data) { $column_name = NULL; if ($column_data['hour_column'] == 'regular_time') { $export_data_map[$column_id] = 'regular_time'; } elseif ($column_data['hour_column'] == 'overtime') { $export_data_map[$column_id] = 'overtime'; } elseif ($column_data['hour_column'] >= 3) { $export_data_map[$column_id] = $column_data; } } if (!isset($setup_data['adp']['company_code_value'])) { $setup_data['adp']['company_code_value'] = NULL; } if (!isset($setup_data['adp']['batch_id_value'])) { $setup_data['adp']['batch_id_value'] = NULL; } if (!isset($setup_data['adp']['temp_dept_value'])) { $setup_data['adp']['temp_dept_value'] = NULL; } $company_code_column = Misc::trimSortPrefix($setup_data['adp']['company_code']); $batch_id_column = Misc::trimSortPrefix($setup_data['adp']['batch_id']); $temp_dept_column = Misc::trimSortPrefix($setup_data['adp']['temp_dept']); foreach ($rows as $row) { $static_columns = array('company_code' => isset($row[$company_code_column]) ? $row[$company_code_column] : $setup_data['adp']['company_code_value'], 'batch_id' => isset($row[$batch_id_column]) ? $row[$batch_id_column] : $setup_data['adp']['batch_id_value'], 'temp_dept' => isset($row[$temp_dept_column]) ? $row[$temp_dept_column] : $setup_data['adp']['temp_dept_value'], 'employee_number' => str_pad($row['employee_number'], 6, 0, STR_PAD_LEFT)); foreach ($setup_data['adp']['columns'] as $column_id => $column_data) { $column_data = Misc::trimSortPrefix($column_data, TRUE); Debug::Text('ADP Column ID: ' . $column_id . ' Hour Column: ' . $column_data['hour_column'] . ' Code: ' . $column_data['hour_code'], __FILE__, __LINE__, __METHOD__, 10); if (isset($row[$column_id]) and $column_data['hour_column'] != '0') { foreach ($export_column_map as $export_column_id => $export_column_name) { Debug::Arr($row, 'Row: Column ID: ' . $column_id . ' Export Column ID: ' . $export_column_id . ' Name: ' . $export_column_name, __FILE__, __LINE__, __METHOD__, 10); if (($column_data['hour_column'] == $export_column_id or $column_data['hour_column'] . '_code' == $export_column_id) and !in_array($export_column_id, array('company_code', 'batch_id', 'temp_dept', 'employee_number'))) { if ((int) substr($export_column_id, 0, 1) > 0) { $tmp_row[$column_data['hour_column'] . '_code'] = $column_data['hour_code']; $tmp_row[$column_data['hour_column'] . '_amount'] = TTDate::getTimeUnit($row[$column_id], 20); } else { $tmp_row[$export_column_id] = TTDate::getTimeUnit($row[$column_id], 20); } //Break out every column onto its own row, that way its easier to handle multiple columns of the same type. $tmp_rows[] = array_merge($static_columns, $tmp_row); unset($tmp_row); } } } } } $file_name = 'EPI000000.csv'; if (isset($tmp_rows)) { //File format supports multiple entries per employee (file #) all using the same columns. No need to jump through nasty hoops to fit everyone one row. $file_name = 'EPI' . $tmp_rows[0]['company_code'] . $tmp_rows[0]['batch_id'] . '.csv'; $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'adp_old': //ADP export format. $file_name = 'EPI' . $setup_data['adp']['company_code'] . $setup_data['adp']['batch_id'] . '.csv'; $export_column_map = array(); $static_export_column_map = array('company_code' => 'Co Code', 'batch_id' => 'Batch ID', 'employee_number' => 'File #'); $static_export_data_map = array('company_code' => $setup_data['adp']['company_code'], 'batch_id' => $setup_data['adp']['batch_id']); // //Format allows for multiple duplicate columns. //ie: Hours 3 Code, Hours 3 Amount, Hours 3 Code, Hours 3 Amount, ... //However, we can only have a SINGLE O/T Hours column. //We also need to combine hours with the same code together. // ksort($setup_data['adp']['columns']); $setup_data['adp']['columns'] = Misc::trimSortPrefix($setup_data['adp']['columns']); foreach ($setup_data['adp']['columns'] as $column_id => $column_data) { $column_name = NULL; if ($column_data['hour_column'] == 'regular_time') { $column_name = 'Reg Hours'; $export_data_map[$column_id] = trim($setup_data['adp']['columns'][$column_id]['hour_code']); } elseif ($column_data['hour_column'] == 'overtime') { $column_name = 'O/T Hours'; $export_data_map[$column_id] = trim($setup_data['adp']['columns'][$column_id]['hour_code']); } elseif ($column_data['hour_column'] >= 3) { $column_name = 'Hours ' . $column_data['hour_column'] . ' Amount'; $export_column_map[$setup_data['adp']['columns'][$column_id]['hour_code'] . '_code'] = 'Hours ' . $column_data['hour_column'] . ' Code'; $export_data_map[$column_id] = trim($setup_data['adp']['columns'][$column_id]['hour_code']); } if ($column_name != '') { $export_column_map[trim($setup_data['adp']['columns'][$column_id]['hour_code'])] = $column_name; } } $export_column_map = Misc::prependArray($static_export_column_map, $export_column_map); // //Combine time from all columns with the same hours code. // $i = 0; foreach ($rows as $row) { foreach ($static_export_column_map as $column_id => $column_name) { if (isset($static_export_data_map[$column_id])) { //Copy over static config values like company code/batch_id. $tmp_rows[$i][$column_id] = $static_export_data_map[$column_id]; } elseif (isset($row[$column_id])) { if (isset($static_export_column_map[$column_id])) { //Copy over employee_number. (File #) $tmp_rows[$i][$column_id] = $row[$column_id]; } } } foreach ($export_data_map as $column_id => $column_name) { if (!isset($tmp_rows[$i][$column_name])) { $tmp_rows[$i][$column_name] = 0; } if (isset($row[$column_id])) { $tmp_rows[$i][$column_name] += $row[$column_id]; } $tmp_rows[$i][$column_name . '_code'] = $column_name; } $i++; } //Convert time from seconds to hours. $convert_unit_columns = array_keys($static_export_column_map); foreach ($tmp_rows as $row => $data) { foreach ($data as $column_id => $column_data) { //var_dump($column_id,$column_data); if (is_int($column_data) and !in_array($column_id, $convert_unit_columns)) { $tmp_rows[$row][$column_id] = TTDate::getTimeUnit($column_data, 20); } } } unset($row, $data, $column_id, $column_data); $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE); break; case 'paychex_preview_advanced_job': //PayChex Preview with job information unset($rows); //Ignore any existing timesheet summary data, we will be using our own job data below. //Debug::Arr($setup_data, 'PayChex Advanced Job Setup Data: ', __FILE__, __LINE__, __METHOD__,10); $config['columns'][] = 'employee_number'; $config['columns'][] = 'date_stamp'; $config['columns'] = array_merge($config['columns'], (array) $setup_data['paychex_preview_advanced_job']['job_columns']); $config['columns'][] = $setup_data['paychex_preview_advanced_job']['state_columns']; $config['columns'] += array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns'))); $config['group'][] = 'employee_number'; $config['group'][] = 'date_stamp'; $config['group'] = array_merge($config['columns'], (array) $setup_data['paychex_preview_advanced_job']['job_columns']); $config['group'][] = $setup_data['paychex_preview_advanced_job']['state_columns']; $config['sort'][] = array('employee_number' => 'asc'); $config['sort'][] = array('date_stamp' => 'asc'); //Debug::Arr($config, 'Job Detail Report Config: ', __FILE__, __LINE__, __METHOD__,10); //Get job data... $jar = TTNew('JobDetailReport'); $jar->setAMFMessageID($this->getAMFMessageID()); $jar->setUserObject($this->getUserObject()); $jar->setPermissionObject($this->getPermissionObject()); $jar->setConfig($config); $jar->setFilterConfig($this->getFilterConfig()); $jar->setSortConfig($config['sort']); $jar->_getData(); $jar->_preProcess(); $jar->sort(); $rows = $jar->data; //Debug::Arr($rows, 'Raw Rows: ', __FILE__, __LINE__, __METHOD__,10); //Need to get job data from job report instead of TimeSheet Summary report. if (!isset($setup_data['paychex_preview_advanced_job']['client_number'])) { $setup_data['paychex_preview_advanced_job']['client_number'] = '0000'; } $file_name = $setup_data['paychex_preview_advanced_job']['client_number'] . '_TA.txt'; ksort($setup_data['paychex_preview_advanced_job']['columns']); $setup_data['paychex_preview_advanced_job']['columns'] = Misc::trimSortPrefix($setup_data['paychex_preview_advanced_job']['columns']); $data = NULL; foreach ($rows as $row) { foreach ($setup_data['paychex_preview_advanced_job']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { $data .= str_pad($row['employee_number'], 6, ' ', STR_PAD_LEFT); $data .= str_pad('', 31, ' ', STR_PAD_LEFT); //Blank space. if (isset($setup_data['paychex_preview_advanced_job']['job_columns']) and is_array($setup_data['paychex_preview_advanced_job']['job_columns'])) { $job_column = array(); foreach ($setup_data['paychex_preview_advanced_job']['job_columns'] as $tmp_job_column) { $job_column[] = isset($row[$tmp_job_column]) ? $row[$tmp_job_column] : NULL; } $data .= str_pad(substr(implode('-', $job_column), 0, 12), 12, ' ', STR_PAD_LEFT); unset($job_column); } else { $data .= str_pad('', 12, ' ', STR_PAD_LEFT); } $data .= str_pad('', 1, ' ', STR_PAD_LEFT); //Shift identifier. //Allow user to specify three digit hour codes to specify their own E/D codes. If codes are two digit, always use E. if (strlen(trim($column_data['hour_code'])) < 3) { $column_data['hour_code'] = 'E' . trim($column_data['hour_code']); } //Should start at col51 $data .= str_pad(substr(trim($column_data['hour_code']), 0, 3), 3, ' ', STR_PAD_RIGHT); if (isset($setup_data['paychex_preview_advanced_job']['include_hourly_rate']) and $setup_data['paychex_preview_advanced_job']['include_hourly_rate'] == TRUE) { $data .= str_pad(isset($row[$column_id . '_hourly_rate']) ? number_format($row[$column_id . '_hourly_rate'], 4, '.', '') : NULL, 9, 0, STR_PAD_LEFT); //Override rate } else { $data .= str_pad('', 9, 0, STR_PAD_LEFT); //Override rate } $data .= str_pad(TTDate::getTimeUnit($row[$column_id], 20), 8, 0, STR_PAD_LEFT); //Break out time by day. $data .= str_pad(TTDate::getYear($row['time_stamp']), 4, 0, STR_PAD_LEFT); //Year, based on time_stamp epoch column $data .= str_pad(TTDate::getMonth($row['time_stamp']), 2, 0, STR_PAD_LEFT); //Month, based on time_stamp epoch column. Can be space padded. $data .= str_pad(TTDate::getDayOfMonth($row['time_stamp']), 2, 0, STR_PAD_LEFT); //Day, based on time_stamp epoch column. Can be space padded. $data .= str_pad('', 4, ' ', STR_PAD_LEFT); //Filler $data .= str_pad('', 9, ' ', STR_PAD_LEFT); //Amount. This can always be calculated from hours and hourly rate above though. $data .= str_pad('', 13, ' ', STR_PAD_LEFT); //Blank space if (isset($setup_data['paychex_preview_advanced_job']['state_columns'])) { $data .= str_pad(isset($row[$setup_data['paychex_preview_advanced_job']['state_columns']]) ? $row[$setup_data['paychex_preview_advanced_job']['state_columns']] : NULL, 2, ' ', STR_PAD_LEFT); //State } $data .= "\n"; } } } break; case 'paychex_preview': //Paychex Preview export format. //Add an advanced PayChex Preview format that supports rates perhaps? //http://kb.idb-sys.com/KnowledgebaseArticle10013.aspx if (!isset($setup_data['paychex_preview']['client_number'])) { $setup_data['paychex_preview']['client_number'] = '0000'; } $file_name = $setup_data['paychex_preview']['client_number'] . '_TA.txt'; ksort($setup_data['paychex_preview']['columns']); $setup_data['paychex_preview']['columns'] = Misc::trimSortPrefix($setup_data['paychex_preview']['columns']); $data = NULL; foreach ($rows as $row) { foreach ($setup_data['paychex_preview']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { $data .= str_pad($row['employee_number'], 6, ' ', STR_PAD_LEFT); $data .= str_pad('E' . str_pad(trim($column_data['hour_code']), 2, ' ', STR_PAD_RIGHT), 47, ' ', STR_PAD_LEFT); $data .= str_pad(str_pad(TTDate::getTimeUnit($row[$column_id], 20), 8, 0, STR_PAD_LEFT), 17, ' ', STR_PAD_LEFT) . "\n"; } } } break; case 'paychex_online': //Paychex Online Payroll CSV ksort($setup_data['paychex_online']['columns']); $setup_data['paychex_online']['columns'] = Misc::trimSortPrefix($setup_data['paychex_online']['columns']); $earnings = array(); //Find all the hours codes foreach ($setup_data['paychex_online']['columns'] as $column_id => $column_data) { $hour_code = $column_data['hour_code']; $earnings[] = $hour_code; } $export_column_map['employee_number'] = ''; foreach ($earnings as $key => $value) { $export_column_map[$value] = ''; } $i = 0; foreach ($rows as $row) { if ($i == 0) { //Include header. $tmp_row['employee_number'] = 'Employee Number'; foreach ($earnings as $key => $value) { $tmp_row[$value] = $value . ' Hours'; } $tmp_rows[] = $tmp_row; unset($tmp_row); } //Combine all hours from the same code together. foreach ($setup_data['paychex_online']['columns'] as $column_id => $column_data) { $hour_code = trim($column_data['hour_code']); if (isset($row[$column_id]) and $hour_code != '') { if (!isset($tmp_hour_codes[$hour_code])) { $tmp_hour_codes[$hour_code] = 0; } $tmp_hour_codes[$hour_code] = bcadd($tmp_hour_codes[$column_data['hour_code']], $row[$column_id]); //Use seconds for math here. } } if (isset($tmp_hour_codes)) { $tmp_row['employee_number'] = $row['employee_number']; foreach ($tmp_hour_codes as $hour_code => $hours) { $tmp_row[$hour_code] = TTDate::getTimeUnit($hours, 20); } $tmp_rows[] = $tmp_row; unset($tmp_hour_codes, $hour_code, $hours, $tmp_row); } $i++; } if (isset($tmp_rows)) { $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'millenium': //Millenium export format. Also used by Qqest. ksort($setup_data['millenium']['columns']); $setup_data['millenium']['columns'] = Misc::trimSortPrefix($setup_data['millenium']['columns']); $export_column_map = array('employee_number' => '', 'transaction_code' => '', 'hour_code' => '', 'hours' => ''); foreach ($rows as $row) { foreach ($setup_data['millenium']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { $tmp_rows[] = array('employee_number' => $row['employee_number'], 'transaction_code' => 'E', 'hour_code' => trim($column_data['hour_code']), 'hours' => TTDate::getTimeUnit($row[$column_id], 20)); } } } if (isset($tmp_rows)) { $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'ceridian_insync': //Ceridian InSync export format. Needs to be .IMP to import? DOS line endings? if (!isset($setup_data['ceridian_insync']['employer_number']) or $setup_data['ceridian_insync']['employer_number'] == '') { $setup_data['ceridian_insync']['employer_number'] = '0001'; } $file_name = strtolower(trim($setup_data['export_type'])) . '_' . $setup_data['ceridian_insync']['employer_number'] . '_' . date('Y_m_d') . '.imp'; ksort($setup_data['ceridian_insync']['columns']); $setup_data['ceridian_insync']['columns'] = Misc::trimSortPrefix($setup_data['ceridian_insync']['columns']); $export_column_map = array('employer_number' => '', 'import_type_id' => '', 'employee_number' => '', 'check_type' => '', 'hour_code' => '', 'value' => '', 'distribution' => '', 'rate' => '', 'premium' => '', 'day' => '', 'pay_period' => ''); foreach ($rows as $row) { foreach ($setup_data['ceridian_insync']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { $tmp_rows[] = array('employer_number' => $setup_data['ceridian_insync']['employer_number'], 'import_type_id' => 'COSTING', 'employee_number' => str_pad($row['employee_number'], 9, '0', STR_PAD_LEFT), 'check_type' => 'REG', 'hour_code' => trim($column_data['hour_code']), 'value' => TTDate::getTimeUnit($row[$column_id], 20), 'distribution' => NULL, 'rate' => NULL, 'premium' => NULL, 'day' => NULL, 'pay_period' => NULL); } } } if (isset($tmp_rows)) { $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE, "\r\n"); //Use DOS line endings only. } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'quickbooks': //Quickbooks Pro export format. //Quickbooks Pro export format. case 'quickbooks_advanced': //Quickbooks Pro export format. $file_name = 'payroll_export.iif'; ksort($setup_data['quickbooks']['columns']); $setup_data['quickbooks']['columns'] = Misc::trimSortPrefix($setup_data['quickbooks']['columns']); // // Quickbooks header // /* Company Create Time can be found by first running an Timer Activity export in QuickBooks and viewing the output. PITEM field needs to be populated, as that is the PAYROLL ITEM in quickbooks. It can be the same as the ITEM field. ITEM is the service item, can be mapped to department/task? PROJ could be mapped to the default department/branch? */ $data = "!TIMERHDR\tVER\tREL\tCOMPANYNAME\tIMPORTEDBEFORE\tFROMTIMER\tCOMPANYCREATETIME\n"; $data .= "TIMERHDR\t8\t0\t" . trim($setup_data['quickbooks']['company_name']) . "\tN\tY\t" . trim($setup_data['quickbooks']['company_created_date']) . "\n"; $data .= "!TIMEACT\tDATE\tJOB\tEMP\tITEM\tPITEM\tDURATION\tPROJ\tNOTE\tXFERTOPAYROLL\tBILLINGSTATUS\n"; foreach ($rows as $row) { foreach ($setup_data['quickbooks']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { //Make sure employee name is in format: LastName, FirstName MiddleInitial $tmp_employee_name = $row['last_name'] . ', ' . $row['first_name']; if (isset($row['middle_name']) and strlen($row['middle_name']) > 0) { $tmp_employee_name .= ' ' . substr(trim($row['middle_name']), 0, 1); } $proj = NULL; if (isset($row[$setup_data['quickbooks']['proj']])) { $proj = $row[$setup_data['quickbooks']['proj']]; } $item = NULL; if (isset($row[$setup_data['quickbooks']['item']])) { $item = $row[$setup_data['quickbooks']['item']]; } $job = NULL; if (isset($row[$setup_data['quickbooks']['job']])) { $job = $row[$setup_data['quickbooks']['job']]; } $data .= "TIMEACT\t" . date('n/j/y', $row['pay_period_end_date']) . "\t" . $job . "\t" . $tmp_employee_name . "\t" . $item . "\t" . trim($column_data['hour_code']) . "\t" . TTDate::getTimeUnit($row[$column_id], 10) . "\t" . $proj . "\t\tY\t0\n"; unset($tmp_employee_name); } } } break; case 'surepayroll': //SurePayroll Export format. ksort($setup_data['surepayroll']['columns']); $setup_data['surepayroll']['columns'] = Misc::trimSortPrefix($setup_data['surepayroll']['columns']); // //header // $data = 'TC' . "\n"; $data .= '00001' . "\n"; $export_column_map = array('pay_period_end_date' => 'Entry Date', 'employee_number' => 'Employee Number', 'last_name' => 'Last Name', 'first_name' => 'First Name', 'hour_code' => 'Payroll Code', 'value' => 'Hours'); foreach ($rows as $row) { foreach ($setup_data['surepayroll']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { //Debug::Arr($column_data,'Output2', __FILE__, __LINE__, __METHOD__,10); $tmp_rows[] = array('pay_period_end_date' => date('m/d/Y', $row['pay_period_end_date']), 'employee_number' => $row['employee_number'], 'last_name' => $row['last_name'], 'first_name' => $row['first_name'], 'hour_code' => trim($column_data['hour_code']), 'value' => TTDate::getTimeUnit($row[$column_id], 20)); } } } if (isset($tmp_rows)) { $data .= Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE); $data = str_replace('"', '', $data); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'chris21': //Chris21 Export format. //Columns required: Employee_number (2), Date (10), ADJUSTMENT_CODE (12), HOURS (13), SIGNED_HOURS(15)[?] //Use SIGNED_HOURS only, as it provides more space? //When using absences a leave start/end date must be specified other it won't be imported. ksort($setup_data['chris21']['columns']); $setup_data['chris21']['columns'] = Misc::trimSortPrefix($setup_data['chris21']['columns']); $data = ''; foreach ($rows as $row) { foreach ($setup_data['chris21']['columns'] as $column_id => $column_data) { if (isset($row[$column_id]) and trim($column_data['hour_code']) != '') { //Debug::Arr($column_data,'Output2: ID: '. $column_id, __FILE__, __LINE__, __METHOD__,10); $data .= str_repeat(' ', 8); //8 digits Blank $data .= str_pad(substr($row['employee_number'], 0, 7), 7, ' ', STR_PAD_RIGHT); //7 digits $data .= str_repeat(' ', 11); //14 digits Blank $data .= date('dmy', $row['pay_period_end_date']); //4 digits Date $data .= str_repeat(' ', 4); //4 digits Blank $data .= str_pad(substr(trim($column_data['hour_code']), 0, 4), 4, ' ', STR_PAD_RIGHT); //4 digits $data .= '0000'; //4 digits HOURS field, always be 0, use SIGNED_HOURS instead. $data .= str_repeat(' ', 4); //CC_CODE: 4 digits Blank $data .= str_pad(str_replace('.', '', TTDate::getTimeUnit($row[$column_id], 20)), 6, 0, STR_PAD_LEFT) . '+'; //SIGNED_HOURS: Hours without decimal padded to 6 digits, with '+' on the end. //$data .= '+000000000'; //Filler: Redefintion of SIGNED_HOURS. $data .= '000000000'; //RATE: 9 chars $data .= str_repeat(' ', 20); //ACCT_NO: 20 chars $data .= str_repeat(' ', 16); //JOB_NUMBER: 16 chars if (strpos($column_id, 'absence') !== FALSE) { //Absence column, include LEAVE dates. $data .= date('dmy', $row['pay_period_end_date']); //LEAVE Start Date: 6 digits $data .= date('dmy', $row['pay_period_end_date']); //LEAVE End Date: 6 digits } $data .= "\n"; } } } unset($tmp_rows, $column_id, $column_data, $rows, $row); break; case 'csv': //Generic CSV. $file_name = strtolower(trim($setup_data['export_type'])) . '_' . date('Y_m_d') . '.csv'; //If this needs to be customized, they can just export any regular report. This could probably be removed completely except for the Hour Code mapping... ksort($setup_data['csv']['columns']); $setup_data['csv']['columns'] = Misc::trimSortPrefix($setup_data['csv']['columns']); $export_column_map = array('employee' => '', 'employee_number' => '', 'default_branch' => '', 'default_department' => '', 'pay_period' => '', 'branch_name' => '', 'department_name' => '', 'hour_code' => '', 'hours' => ''); $i = 0; foreach ($rows as $row) { if ($i == 0) { //Include header. $tmp_rows[] = array('employee' => 'Employee', 'employee_number' => 'Employee Number', 'default_branch' => 'Default Branch', 'default_department' => 'Default Department', 'pay_period' => 'Pay Period', 'branch_name' => 'Branch', 'department_name' => 'Department', 'hour_code' => 'Hours Code', 'hours' => 'Hours'); } //Combine all hours from the same code together. foreach ($setup_data['csv']['columns'] as $column_id => $column_data) { $hour_code = trim($column_data['hour_code']); if (isset($row[$column_id]) and $hour_code != '') { if (!isset($tmp_hour_codes[$hour_code])) { $tmp_hour_codes[$hour_code] = 0; } $tmp_hour_codes[$hour_code] = bcadd($tmp_hour_codes[$column_data['hour_code']], $row[$column_id]); //Use seconds for math here. } } if (isset($tmp_hour_codes)) { foreach ($tmp_hour_codes as $hour_code => $hours) { $tmp_rows[] = array('employee' => isset($row['full_name']) ? $row['full_name'] : NULL, 'employee_number' => isset($row['employee_number']) ? $row['employee_number'] : NULL, 'default_branch' => isset($row['default_branch']) ? $row['default_branch'] : NULL, 'default_department' => isset($row['default_department']) ? $row['default_department'] : NULL, 'pay_period' => isset($row['pay_period']['display']) ? $row['pay_period']['display'] : NULL, 'branch_name' => isset($row['branch_name']) ? $row['branch_name'] : NULL, 'department_name' => isset($row['department_name']) ? $row['department_name'] : NULL, 'hour_code' => $hour_code, 'hours' => TTDate::getTimeUnit($hours, 20)); } unset($tmp_hour_codes, $hour_code, $hours); } $i++; } if (isset($tmp_rows)) { $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; case 'csv_advanced': //Generic CSV. unset($rows); //Ignore any existing timesheet summary data, we will be using our own job data below. //If this needs to be customized, they can just export any regular report. This could probably be removed completely except for the Hour Code mapping... if (!isset($setup_data['csv_advanced']['export_columns']) or isset($setup_data['csv_advanced']['export_columns']) and !is_array($setup_data['csv_advanced']['export_columns'])) { $setup_data['csv_advanced']['export_columns'] = array('full_name', 'employee_number', 'default_branch', 'default_department', 'pay_period', 'date_stamp'); } if (isset($setup_data['csv_advanced']['export_columns']) and is_array($setup_data['csv_advanced']['export_columns'])) { //Debug::Arr($setup_data['csv_advanced']['export_columns'], 'Custom Columns defined: ', __FILE__, __LINE__, __METHOD__,10); $config['columns'] = $config['group'] = $setup_data['csv_advanced']['export_columns']; //Force sorting... foreach ($setup_data['csv_advanced']['export_columns'] as $export_column) { $config['sort'][] = array($export_column => 'asc'); } $config['columns'] += array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns'))); } Debug::Arr($config, 'Job Detail Report Config: ', __FILE__, __LINE__, __METHOD__, 10); //Get job data... if (is_object($this->getUserObject()) and is_object($this->getUserObject()->getCompanyObject()) and $this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { Debug::Text('Using Job Detail Report...', __FILE__, __LINE__, __METHOD__, 10); $jar = TTNew('JobDetailReport'); } else { Debug::Text('Using TimeSheet Detail Report...', __FILE__, __LINE__, __METHOD__, 10); $jar = TTNew('TimesheetDetailReport'); } $jar->setAMFMessageID($this->getAMFMessageID()); $jar->setUserObject($this->getUserObject()); $jar->setPermissionObject($this->getPermissionObject()); $jar->setConfig($config); $jar->setFilterConfig($this->getFilterConfig()); $jar->setSortConfig($config['sort']); $jar->_getData(); $jar->_preProcess(); $jar->group(); $jar->sort(); $columns = Misc::trimSortPrefix($jar->getOptions('columns')); $rows = $jar->data; //Debug::Arr($rows, 'Raw Rows: ', __FILE__, __LINE__, __METHOD__,10); $file_name = strtolower(trim($setup_data['export_type'])) . '_' . date('Y_m_d') . '.csv'; //If this needs to be customized, they can just export any regular report. This could probably be removed completely except for the Hour Code mapping... ksort($setup_data['csv_advanced']['columns']); $setup_data['csv_advanced']['columns'] = Misc::trimSortPrefix($setup_data['csv_advanced']['columns']); foreach ($setup_data['csv_advanced']['export_columns'] as $export_column) { $export_column_map[$export_column] = ''; } $export_column_map['hour_code'] = ''; $export_column_map['hours'] = ''; $i = 0; foreach ($rows as $row) { if ($i == 0) { //Include header. foreach ($setup_data['csv_advanced']['export_columns'] as $export_column) { Debug::Text('Header Row: ' . $export_column, __FILE__, __LINE__, __METHOD__, 10); $tmp_rows[$i][$export_column] = isset($columns[$export_column]) ? $columns[$export_column] : NULL; } $tmp_rows[$i]['hour_code'] = 'Hours Code'; $tmp_rows[$i]['hours'] = 'Hours'; $i++; } //Combine all hours from the same code together. foreach ($setup_data['csv_advanced']['columns'] as $column_id => $column_data) { $hour_code = trim($column_data['hour_code']); if (isset($row[$column_id]) and $hour_code != '') { if (!isset($tmp_hour_codes[$hour_code])) { $tmp_hour_codes[$hour_code] = 0; } $tmp_hour_codes[$hour_code] = bcadd($tmp_hour_codes[$column_data['hour_code']], $row[$column_id]); //Use seconds for math here. } } if (isset($tmp_hour_codes)) { foreach ($tmp_hour_codes as $hour_code => $hours) { foreach ($setup_data['csv_advanced']['export_columns'] as $export_column) { $tmp_rows[$i][$export_column] = isset($row[$export_column]) ? isset($row[$export_column]['display']) ? $row[$export_column]['display'] : $row[$export_column] : NULL; $tmp_rows[$i]['hour_code'] = $hour_code; $tmp_rows[$i]['hours'] = TTDate::getTimeUnit($hours, 20); } } unset($tmp_hour_codes, $hour_code, $hours); } $i++; } //Debug::Arr($tmp_rows, 'Tmp Rows: ', __FILE__, __LINE__, __METHOD__,10); if (isset($tmp_rows)) { $data = Misc::Array2CSV($tmp_rows, $export_column_map, FALSE, FALSE); } unset($tmp_rows, $export_column_map, $column_id, $column_data, $rows, $row); break; default: //Send raw data so plugin can capture it and change it if needed. $data = $this->data; break; } //Debug::Arr($data, 'Export Data: ', __FILE__, __LINE__, __METHOD__,10); return array('file_name' => $file_name, 'mime_type' => $mime_type, 'data' => $data); }
function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print' or $format == 'pdf_form_print_government') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $current_user = $this->getUserObject(); if (!is_object($current_user)) { Debug::Text('Invalid user object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } $this->sortFormData(); //Make sure forms are sorted. $f1099m = $this->getF1099MiscObject(); $f1099m->setDebug(FALSE); $f1099m->setShowBackground($show_background); if (stristr($format, 'government')) { $form_type = 'government'; } else { $form_type = 'employee'; } Debug::Text('Form Type: ' . $form_type, __FILE__, __LINE__, __METHOD__, 10); $f1099m->setType($form_type); $f1099m->year = TTDate::getYear($filter_data['end_date']); //Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually. $f1099m->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $f1099m->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName(); $f1099m->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $f1099m->company_address1 = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $f1099m->company_city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $f1099m->company_state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $f1099m->company_zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); if (isset($this->form_data) and count($this->form_data) > 0) { $i = 0; $n = 1; foreach ((array) $this->form_data as $row) { if (!isset($row['user_id'])) { Debug::Text('User ID not set!', __FILE__, __LINE__, __METHOD__, 10); continue; } $ulf = TTnew('UserListFactory'); $ulf->getById((int) $row['user_id']); if ($ulf->getRecordCount() == 1) { $user_obj = $ulf->getCurrent(); $ee_data = array('control_number' => $n, 'first_name' => $user_obj->getFirstName(), 'middle_name' => $user_obj->getMiddleName(), 'last_name' => $user_obj->getLastName(), 'address1' => $user_obj->getAddress1(), 'address2' => $user_obj->getAddress2(), 'city' => $user_obj->getCity(), 'state' => $user_obj->getProvince(), 'employment_province' => $user_obj->getProvince(), 'postal_code' => $user_obj->getPostalCode(), 'ssn' => $user_obj->getSIN(), 'employee_number' => $user_obj->getEmployeeNumber(), 'l4' => $row['l4'], 'l6' => $row['l6'], 'l7' => $row['l7']); foreach (range('a', 'z') as $z) { //State income tax if (isset($row['l16' . $z])) { if (isset($setup_data['state'][$row['l17' . $z . '_state']])) { $ee_data['l17' . $z . '_state_id'] = $setup_data['state'][$row['l17' . $z . '_state']]['state_id']; } $ee_data['l17' . $z] = $row['l17' . $z . '_state']; if (isset($ee_data['l17' . $z . '_state_id'])) { $ee_data['l17' . $z] .= ' / ' . $ee_data['l17' . $z . '_state_id']; } $ee_data['l16' . $z] = $row['l16' . $z]; $ee_data['l18' . $z] = $row['l18' . $z]; } } $f1099m->addRecord($ee_data); unset($ee_data); $i++; $n++; } } } $this->getFormObject()->addForm($f1099m); if ($format == 'efile_xml') { $output_format = 'XML'; $file_name = 'w2_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); return $output; }
function calcAccrualPolicyTime($u_obj, $epoch, $offset, $pps_obj, $pay_period_arr, $accrual_balance, $update_records = TRUE) { $retval = 0; Debug::Text('User: '******' Status: ' . $u_obj->getStatus() . ' Epoch: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10); //Make sure only active employees accrue time *after* their hire date. //Will this negative affect Employees who may be on leave? if ($u_obj->getStatus() == 10 and $epoch >= $u_obj->getHireDate() and ($this->getMinimumEmployedDays() == 0 or TTDate::getDays($epoch - $u_obj->getHireDate()) >= $this->getMinimumEmployedDays())) { Debug::Text(' User is active and has been employed long enough.', __FILE__, __LINE__, __METHOD__, 10); $annual_pay_periods = $pps_obj->getAnnualPayPeriods(); $in_apply_frequency_window = FALSE; $in_apply_rollover_window = FALSE; $pay_period_start_date = NULL; $accrual_amount = 0; if ($this->getType() == 30) { Debug::Text(' Accrual policy is hour based, real-time window.', __FILE__, __LINE__, __METHOD__, 10); //Hour based, apply frequency is real-time. $in_apply_frequency_window = TRUE; } else { if ($this->getApplyFrequency() == 10) { $pay_period_dates = $this->getPayPeriodDatesFromArray($pay_period_arr, $epoch - $offset); if (is_array($pay_period_dates)) { Debug::Text(' Pay Period Start Date: ' . TTDate::getDate('DATE+TIME', $pay_period_dates['start_date']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $pay_period_dates['end_date']), __FILE__, __LINE__, __METHOD__, 10); if ($this->inApplyFrequencyWindow($epoch, $offset, $pay_period_dates['end_date']) == TRUE) { $in_apply_frequency_window = TRUE; $pay_period_start_date = $pay_period_dates['start_date']; //Used for inRolloverFrequencyWindow } else { Debug::Text(' User not in Apply Frequency Window: ', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::Arr($pay_period_dates, ' No Pay Period Dates Found.', __FILE__, __LINE__, __METHOD__, 10); } } elseif ($this->inApplyFrequencyWindow($epoch, $offset, NULL, $u_obj->getHireDate()) == TRUE) { Debug::Text(' User IS in NON-PayPeriod Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10); $in_apply_frequency_window = TRUE; } else { Debug::Text(' User is not in Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10); $in_apply_frequency_window = FALSE; } } if ($this->inRolloverFrequencyWindow($epoch, $offset, $u_obj->getHireDate(), $pay_period_start_date)) { Debug::Text(' In rollover window...', __FILE__, __LINE__, __METHOD__, 10); $in_apply_rollover_window = TRUE; } if ($in_apply_frequency_window == TRUE or $in_apply_rollover_window == TRUE) { $milestone_obj = $this->getActiveMilestoneObject($u_obj, $epoch); } if ($in_apply_rollover_window == TRUE and (isset($milestone_obj) and is_object($milestone_obj))) { //Have accrual balance passed in for optimization //$accrual_balance = $this->getCurrentAccrualBalance( $u_obj->getID(), $this->getId() ); //Handle maximum rollover adjustments before continuing. if ($accrual_balance > $milestone_obj->getRolloverTime()) { $rollover_accrual_adjustment = bcsub($milestone_obj->getRolloverTime(), $accrual_balance, 0); Debug::Text(' Adding rollover adjustment of: ' . $rollover_accrual_adjustment, __FILE__, __LINE__, __METHOD__, 10); //Check to make sure there isn't an identical entry already made. //Ignore rollover adjustment is another adjustment of any amount has been made on the same day. $alf = TTnew('AccrualListFactory'); if ($update_records == TRUE) { $alf->getByCompanyIdAndUserIdAndAccrualPolicyIDAndTypeIDAndTimeStamp($u_obj->getCompany(), $u_obj->getID(), $this->getId(), 60, TTDate::getMiddleDayEpoch($epoch)); } if ($alf->getRecordCount() == 0) { //Get effective date, try to use the current milestone rollover date to make things more clear. $current_milestone_rollover_date = $this->getCurrentMilestoneRolloverDate($epoch, $u_obj->getHireDate()); //If milestone rollover date comes after the current epoch, back date it by one year. if ($current_milestone_rollover_date > $epoch) { $current_milestone_rollover_date = mktime(0, 0, 0, TTDate::getMonth($current_milestone_rollover_date), TTDate::getDayOfMonth($current_milestone_rollover_date), TTDate::getYear($epoch) - 1); } if ($update_records == TRUE) { //Don't round to the nearest minute, as that can cause too much error on weekly frequencies. $af = TTnew('AccrualFactory'); $af->setUser($u_obj->getID()); $af->setType(60); //Rollover Adjustment $af->setAccrualPolicyID($this->getId()); $af->setAmount($rollover_accrual_adjustment); $af->setTimeStamp(TTDate::getMiddleDayEpoch($current_milestone_rollover_date)); $af->setEnableCalcBalance(TRUE); if ($af->isValid()) { $af->Save(); } } else { Debug::Text(' NOT UPDATING RECORDS...', __FILE__, __LINE__, __METHOD__, 10); $retval = $rollover_accrual_adjustment; } //Make sure we get updated balance after rollover adjustment was made. $accrual_balance += $rollover_accrual_adjustment; unset($current_milestone_rollover_date); } else { Debug::Text(' Found duplicate rollover accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::Text(' Balance hasnt exceeded rollover adjustment...', __FILE__, __LINE__, __METHOD__, 10); } unset($rollover_accrual_adjustment, $alf, $af); } if ($in_apply_frequency_window === TRUE) { if (isset($milestone_obj) and is_object($milestone_obj)) { Debug::Text(' Found Matching Milestone, Accrual Rate: (ID: ' . $milestone_obj->getId() . ') ' . $milestone_obj->getAccrualRate() . '/year', __FILE__, __LINE__, __METHOD__, 10); //Make sure we get updated balance after rollover adjustment was made. //Have accrual balance passed in for optimization //$accrual_balance = $this->getCurrentAccrualBalance( $u_obj->getID(), $this->getId() ); if ($accrual_balance < $milestone_obj->getMaximumTime()) { $accrual_amount = $this->calcAccrualAmount($milestone_obj, 0, $annual_pay_periods); if ($accrual_amount > 0) { $new_accrual_balance = bcadd($accrual_balance, $accrual_amount); //If Maximum time is set to 0, make that unlimited. if ($milestone_obj->getMaximumTime() > 0 and $new_accrual_balance > $milestone_obj->getMaximumTime()) { $accrual_amount = bcsub($milestone_obj->getMaximumTime(), $accrual_balance, 0); } Debug::Text(' Min/Max Adjusted Accrual Amount: ' . $accrual_amount . ' Limits: Min: ' . $milestone_obj->getMinimumTime() . ' Max: ' . $milestone_obj->getMaximumTime(), __FILE__, __LINE__, __METHOD__, 10); //Check to make sure there isn't an identical entry already made. $alf = TTnew('AccrualListFactory'); if ($update_records == TRUE) { $alf->getByCompanyIdAndUserIdAndAccrualPolicyIDAndTimeStampAndAmount($u_obj->getCompany(), $u_obj->getID(), $this->getId(), TTDate::getMiddleDayEpoch($epoch), $accrual_amount); } if ($alf->getRecordCount() == 0) { if ($update_records == TRUE) { Debug::Text(' UPDATING RECORDS...', __FILE__, __LINE__, __METHOD__, 10); //Round to nearest 1min $af = TTnew('AccrualFactory'); $af->setUser($u_obj->getID()); $af->setType(75); //Accrual Policy $af->setAccrualPolicyID($this->getId()); $af->setAmount($accrual_amount); $af->setTimeStamp(TTDate::getMiddleDayEpoch($epoch)); $af->setEnableCalcBalance(TRUE); if ($af->isValid()) { $af->Save(); } } else { Debug::Text(' NOT UPDATING RECORDS...', __FILE__, __LINE__, __METHOD__, 10); $retval += $accrual_amount; } } else { Debug::Text(' Found duplicate accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10); } unset($accrual_amount, $accrual_balance, $new_accrual_balance); } else { Debug::Text(' Accrual Amount is 0...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::Text(' Accrual Balance is outside Milestone Range. Skipping...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::Text(' DID NOT Find Matching Milestone.', __FILE__, __LINE__, __METHOD__, 10); } unset($milestone_obj); } } else { Debug::Text(' User is not active (Status: ' . $u_obj->getStatus() . ') or has only been employed: ' . TTDate::getDays($epoch - $u_obj->getHireDate()) . ' Days, not enough. Hire Date: ' . TTDate::getDATE('DATE+TIME', $u_obj->getHireDate()), __FILE__, __LINE__, __METHOD__, 10); } if ($update_records == TRUE) { return TRUE; } else { Debug::Text('Retval: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); return $retval; } }
static function inApplyFrequencyWindow($frequency_id, $start_date, $end_date, $frequency_criteria = array()) { /* Frequency IDs: 20 => 'Annually', 25 => 'Quarterly', 30 => 'Monthly', 40 => 'Weekly', 100 => 'Specific Date', //Pay Period Dates, Hire Dates, Termination Dates, etc... */ if (!isset($frequency_criteria['month'])) { $frequency_criteria['month'] = 0; } if (!isset($frequency_criteria['day_of_month'])) { $frequency_criteria['day_of_month'] = 0; } if (!isset($frequency_criteria['day_of_week'])) { $frequency_criteria['day_of_week'] = 0; } if (!isset($frequency_criteria['quarter_month'])) { $frequency_criteria['quarter_month'] = 0; } if (!isset($frequency_criteria['date'])) { $frequency_criteria['date'] = 0; } //Debug::Arr($frequency_criteria, 'Freq ID: '. $frequency_id .' Date: Start: '. TTDate::getDate('DATE+TIME', $start_date) .'('.$start_date.') End: '. TTDate::getDate('DATE+TIME', $end_date) .'('.$end_date.')', __FILE__, __LINE__, __METHOD__,10); $retval = FALSE; switch ($frequency_id) { case 20: //Annually $year_epoch1 = mktime(TTDate::getHour($start_date), TTDate::getMinute($start_date), TTDate::getSecond($start_date), $frequency_criteria['month'], $frequency_criteria['day_of_month'], TTDate::getYear($start_date)); $year_epoch2 = mktime(TTDate::getHour($end_date), TTDate::getMinute($end_date), TTDate::getSecond($end_date), $frequency_criteria['month'], $frequency_criteria['day_of_month'], TTDate::getYear($end_date)); //Debug::Text('Year1 EPOCH: '. TTDate::getDate('DATE+TIME', $year_epoch1) .'('. $year_epoch1 .')', __FILE__, __LINE__, __METHOD__,10); //Debug::Text('Year2 EPOCH: '. TTDate::getDate('DATE+TIME', $year_epoch2) .'('. $year_epoch2 .')', __FILE__, __LINE__, __METHOD__,10); if ($year_epoch1 >= $start_date and $year_epoch1 <= $end_date or $year_epoch2 >= $start_date and $year_epoch2 <= $end_date) { $retval = TRUE; } break; case 25: //Quarterly //Handle quarterly like month, we just need to set the specific month from quarter_month. if (abs($end_date - $start_date) > 86400 * 93) { //3 months $retval = TRUE; } else { for ($i = TTDate::getMiddleDayEpoch($start_date); $i <= TTDate::getMiddleDayEpoch($end_date); $i += 86400 * 1) { if (self::getYearQuarterMonthNumber($i) == $frequency_criteria['quarter_month'] and $frequency_criteria['day_of_month'] == self::getDayOfMonth($i)) { $retval = TRUE; break; } } } break; case 30: //Monthly //Make sure if they specify the day of month to be 31, that is still works for months with 30, or 28-29 days, assuming 31 basically means the last day of the month if ($frequency_criteria['day_of_month'] > TTDate::getDaysInMonth($start_date) or $frequency_criteria['day_of_month'] > TTDate::getDaysInMonth($end_date)) { $frequency_criteria['day_of_month'] = TTDate::getDaysInMonth($start_date); if (TTDate::getDaysInMonth($end_date) < $frequency_criteria['day_of_month']) { $frequency_criteria['day_of_month'] = TTDate::getDaysInMonth($end_date); } //Debug::Text('Apply frequency day of month exceeds days in this month, using last day of the month instead: '. $frequency_criteria['day_of_month'], __FILE__, __LINE__, __METHOD__,10); } $month_epoch1 = mktime(TTDate::getHour($start_date), TTDate::getMinute($start_date), TTDate::getSecond($start_date), TTDate::getMonth($start_date), $frequency_criteria['day_of_month'], TTDate::getYear($start_date)); $month_epoch2 = mktime(TTDate::getHour($end_date), TTDate::getMinute($end_date), TTDate::getSecond($end_date), TTDate::getMonth($end_date), $frequency_criteria['day_of_month'], TTDate::getYear($end_date)); //Debug::Text('Day of Month: '. $frequency_criteria['day_of_month'] .' Month EPOCH: '. TTDate::getDate('DATE+TIME', $month_epoch1) .' Current Month: '. TTDate::getMonth( $start_date ), __FILE__, __LINE__, __METHOD__,10); //Debug::Text('Month1 EPOCH: '. TTDate::getDate('DATE+TIME', $month_epoch1) .'('. $month_epoch1 .') Greater Than: '. TTDate::getDate('DATE+TIME', ($start_date)) .' Less Than: '. TTDate::getDate('DATE+TIME', $end_date) .'('. $end_date .')', __FILE__, __LINE__, __METHOD__,10); //Debug::Text('Month2 EPOCH: '. TTDate::getDate('DATE+TIME', $month_epoch2) .'('. $month_epoch2 .') Greater Than: '. TTDate::getDate('DATE+TIME', ($start_date)) .' Less Than: '. TTDate::getDate('DATE+TIME', $end_date) .'('. $end_date .')', __FILE__, __LINE__, __METHOD__,10); if ($month_epoch1 >= $start_date and $month_epoch1 <= $end_date or $month_epoch2 >= $start_date and $month_epoch2 <= $end_date) { $retval = TRUE; } break; case 40: //Weekly $start_dow = self::getDayOfWeek($start_date); $end_dow = self::getDayOfWeek($end_date); if ($start_dow == $frequency_criteria['day_of_week'] or $end_dow == $frequency_criteria['day_of_week']) { $retval = TRUE; } else { if ($end_date - $start_date > 86400 * 7) { $retval = TRUE; } else { for ($i = TTDate::getMiddleDayEpoch($start_date); $i <= TTDate::getMiddleDayEpoch($end_date); $i += 86400) { if (self::getDayOfWeek($i) == $frequency_criteria['day_of_week']) { $retval = TRUE; break; } } } } break; case 100: //Specific date Debug::Text('Specific Date: ' . TTDate::getDate('DATE+TIME', $frequency_criteria['date']), __FILE__, __LINE__, __METHOD__, 10); if ($frequency_criteria['date'] >= $start_date and $frequency_criteria['date'] <= $end_date) { $retval = TRUE; } break; } Debug::Text('Retval ' . (int) $retval, __FILE__, __LINE__, __METHOD__, 10); return $retval; }
function inApplyFrequencyWindow($current_epoch, $offset, $pay_period_end_date = NULL) { $retval = FALSE; switch ($this->getApplyFrequency()) { case 10: //Pay Period if ($pay_period_end_date == '') { return FALSE; } if ($pay_period_end_date >= $current_epoch - $offset and $pay_period_end_date <= $current_epoch) { $retval = TRUE; } break; case 20: //Year $year_epoch = mktime(0, 0, 0, $this->getApplyFrequencyMonth(), $this->getApplyFrequencyDayOfMonth(), TTDate::getYear($current_epoch)); Debug::Text('Year EPOCH: ' . TTDate::getDate('DATE+TIME', $year_epoch), __FILE__, __LINE__, __METHOD__, 10); if ($year_epoch >= $current_epoch - $offset and $year_epoch <= $current_epoch) { $retval = TRUE; } break; case 30: //Month $apply_frequency_day_of_month = $this->getApplyFrequencyDayOfMonth(); //Make sure if they specify the day of month to be 31, that is still works for months with 30, or 28-29 days, assuming 31 basically means the last day of the month if ($apply_frequency_day_of_month > TTDate::getDaysInMonth($current_epoch)) { $apply_frequency_day_of_month = TTDate::getDaysInMonth($current_epoch); Debug::Text('Apply frequency day of month exceeds days in this month, using last day of the month instead: ' . $apply_frequency_day_of_month, __FILE__, __LINE__, __METHOD__, 10); } $month_epoch = mktime(0, 0, 0, TTDate::getMonth($current_epoch), $apply_frequency_day_of_month, TTDate::getYear($current_epoch)); Debug::Text('Day of Month: ' . $this->getApplyFrequencyDayOfMonth() . ' Month EPOCH: ' . TTDate::getDate('DATE+TIME', $month_epoch) . ' Current Month: ' . TTDate::getMonth($current_epoch), __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Month EPOCH: ' . TTDate::getDate('DATE+TIME', $month_epoch) . ' Greater Than: ' . TTDate::getDate('DATE+TIME', $current_epoch - $offset) . ' Less Than: ' . TTDate::getDate('DATE+TIME', $current_epoch), __FILE__, __LINE__, __METHOD__, 10); if ($month_epoch >= $current_epoch - $offset and $month_epoch <= $current_epoch) { $retval = TRUE; } break; case 40: //Week Debug::Text('Current Day Of Week: ' . TTDate::getDayOfWeek($current_epoch - $offset), __FILE__, __LINE__, __METHOD__, 10); if ($this->getApplyFrequencyDayOfWeek() == TTDate::getDayOfWeek($current_epoch - $offset)) { $retval = TRUE; } break; } Debug::Text('RetVal: ' . (int) $retval, __FILE__, __LINE__, __METHOD__, 10); return $retval; }
function _outputPDFForm($format = NULL) { $show_background = TRUE; if ($format == 'pdf_form_print') { $show_background = FALSE; } Debug::Text('Generating Form... Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10); $setup_data = $this->getFormConfig(); $filter_data = $this->getFilterConfig(); //Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__,10); $current_company = $this->getUserObject()->getCompanyObject(); if (!is_object($current_company)) { Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if ($format == 'efile_xml') { $return941 = $this->getRETURN941Object(); $return941->TaxPeriodEndDate = TTDate::getDate('Y-m-d', TTDate::getEndDayEpoch($filter_data['end_date'])); $return941->ReturnType = ''; $return941->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $return941->BusinessName1 = ''; $return941->BusinessNameControl = ''; $return941->AddressLine = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $return941->City = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $return941->State = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $return941->ZIPCode = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $this->getFormObject()->addForm($return941); } $f941 = $this->getF941Object(); $f941->setDebug(FALSE); $f941->setShowBackground($show_background); $f941->year = TTDate::getYear($filter_data['end_date']); //Add support for the user to manually set this data in the setup_data. That way they can use multiple tax IDs for different employees, all beit manually. $f941->ein = (isset($setup_data['ein']) and $setup_data['ein'] != '') ? $setup_data['ein'] : $current_company->getBusinessNumber(); $f941->name = (isset($setup_data['name']) and $setup_data['name'] != '') ? $setup_data['name'] : $this->getUserObject()->getFullName(); $f941->trade_name = (isset($setup_data['company_name']) and $setup_data['company_name'] != '') ? $setup_data['company_name'] : $current_company->getName(); $f941->address = (isset($setup_data['address1']) and $setup_data['address1'] != '') ? $setup_data['address1'] : $current_company->getAddress1() . ' ' . $current_company->getAddress2(); $f941->city = (isset($setup_data['city']) and $setup_data['city'] != '') ? $setup_data['city'] : $current_company->getCity(); $f941->state = (isset($setup_data['province']) and ($setup_data['province'] != '' and $setup_data['province'] != 0)) ? $setup_data['province'] : $current_company->getProvince(); $f941->zip_code = (isset($setup_data['postal_code']) and $setup_data['postal_code'] != '') ? $setup_data['postal_code'] : $current_company->getPostalCode(); $f941->quarter = TTDate::getYearQuarter($filter_data['end_date']); //Debug::Arr($this->form_data, 'Final Data for Form: ', __FILE__, __LINE__, __METHOD__,10); if (isset($this->form_data) and count($this->form_data) == 3) { $f941->l1 = count($this->user_ids); $f941->l2 = $this->form_data['total']['l2']; $f941->l3 = $this->form_data['total']['l3']; $f941->l5a = $this->form_data['total']['l5a']; $f941->l5b = $this->form_data['total']['l5b']; $f941->l5c = $this->form_data['total']['l5c']; $f941->l5d = $this->form_data['total']['l5d']; if (isset($setup_data['quarter_deposit']) and $setup_data['quarter_deposit'] != '') { $f941->l11 = Misc::MoneyFormat($setup_data['quarter_deposit'], FALSE); } //Debug::Text('L11: '. $f941->l11 .' L6: '. $f941->calcL6() .' - '. $this->form_data['total']['l10'] , __FILE__, __LINE__, __METHOD__,10); $f941->l15b = TRUE; if (isset($setup_data['deposit_schedule']) and $setup_data['deposit_schedule'] == 10) { if (isset($this->form_data['quarter'][1]['l10'])) { $f941->l16_month1 = $this->form_data['quarter'][1]['l10']; } if (isset($this->form_data['quarter'][2]['l10'])) { $f941->l16_month2 = $this->form_data['quarter'][2]['l10']; } if (isset($this->form_data['quarter'][3]['l10'])) { $f941->l16_month3 = $this->form_data['quarter'][3]['l10']; } } elseif (isset($setup_data['deposit_schedule']) and $setup_data['deposit_schedule'] == 20) { $f941sb = $this->getFormObject()->getFormObject('941sb', 'US'); $f941sb->setShowBackground($show_background); $f941sb->year = $f941->year; $f941sb->ein = $f941->ein; $f941sb->name = $f941->name; $f941sb->quarter = $f941->quarter; for ($i = 1; $i <= 3; $i++) { if (isset($this->form_data['pay_period'][$i])) { foreach ($this->form_data['pay_period'][$i] as $pay_period_epoch => $data) { //Debug::Text('SB: Month: '. $i .' Pay Period Date: '. TTDate::getDate('DATE', $pay_period_epoch) .' DOM: '. TTDate::getDayOfMonth($pay_period_epoch) .' Amount: '. $data['l10'], __FILE__, __LINE__, __METHOD__,10); $f941sb_data[$i][TTDate::getDayOfMonth($pay_period_epoch)] = $data['l10']; //Don't round this as it can cause mismatches in the totals. } } } if (isset($f941sb_data[1])) { $f941sb->month1 = $f941sb_data[1]; } if (isset($f941sb_data[2])) { $f941sb->month2 = $f941sb_data[2]; } if (isset($f941sb_data[3])) { $f941sb->month3 = $f941sb_data[3]; } unset($i, $d, $f941sb_data); } } else { Debug::Arr($this->data, 'Invalid Form Data: ', __FILE__, __LINE__, __METHOD__, 10); } $this->getFormObject()->addForm($f941); if (isset($f941sb) and is_object($f941sb)) { $this->getFormObject()->addForm($f941sb); } if ($format == 'efile_xml') { $output_format = 'XML'; $file_name = '941_efile_' . date('Y_m_d') . '.xml'; $mime_type = 'applications/octet-stream'; //Force file to download. } else { $output_format = 'PDF'; $file_name = $this->file_name; $mime_type = $this->file_mime_type; } $output = $this->getFormObject()->output($output_format); return $output; }
} default: $data['product_edition'] = Option::getByKey(getTTProductEdition(), $current_company->getOptions('product_edition')); //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 = new CompanyUserCountListFactory(); $cuclf->getMonthlyMinAvgMaxByCompanyIdAndStartDateAndEndDate($current_company->getId(), $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc')); 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')); } } $cjlf = new CronJobListFactory(); $cjlf->getMostRecentlyRun(); if ($cjlf->getRecordCount() > 0) { $cj_obj = $cjlf->getCurrent(); $data['cron'] = array('last_run_date' => $cj_obj->getLastRunDate()); } if (($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; } //Set this so the license upload area at least shows up regardles of edition. $data['license_data'] = array(); $license = new TTLicense();
/** * 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); }