if (isset($company_data['name'])) { $cf->setName($company_data['name']); } $cf->setShortName($company_data['short_name']); $cf->setBusinessNumber($company_data['business_number']); $cf->setOriginatorID($company_data['originator_id']); $cf->setDataCenterID($company_data['data_center_id']); $cf->setAddress1($company_data['address1']); $cf->setAddress2($company_data['address2']); $cf->setCity($company_data['city']); $cf->setCountry($company_data['country']); if (isset($company_data['province'])) { $cf->setProvince($company_data['province']); } $cf->setPostalCode($company_data['postal_code']); $cf->setWorkPhone($company_data['work_phone']); $cf->setFaxPhone($company_data['fax_phone']); $cf->setAdminContact($company_data['admin_contact']); $cf->setBillingContact($company_data['billing_contact']); $cf->setSupportContact($company_data['support_contact']); if (isset($company_data['enable_second_last_name']) and $company_data['enable_second_last_name'] == 1) { $cf->setEnableSecondLastName(TRUE); } else { $cf->setEnableSecondLastName(FALSE); } if ($cf->isNew() == TRUE) { $cf->setEnableAddCurrency(TRUE); $cf->setEnableAddPermissionGroupPreset(TRUE); $cf->setEnableAddStation(TRUE); $cf->setEnableAddPayStubEntryAccountPreset(TRUE); $cf->setEnableAddRecurringHolidayPreset(TRUE);
function createCompany() { $cf = new CompanyFactory(); $cf->setStatus(10); //Active if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL) { $cf->setProductEdition(20); //Professional } else { $cf->setProductEdition(10); //Standard } $cf->setName('ABC Company'); $cf->setShortName('ABC'); $cf->setBusinessNumber('123456789'); //$cf->setOriginatorID( $company_data['originator_id'] ); //$cf->setDataCenterID($company_data['data_center_id']); $cf->setAddress1('123 Main St'); $cf->setAddress2('Unit #123'); $cf->setCity('New York'); $cf->setCountry('US'); $cf->setProvince('NY'); $cf->setPostalCode('12345'); $cf->setWorkPhone('555-555-5555'); $cf->setEnableAddCurrency(FALSE); if ($cf->isValid()) { $insert_id = $cf->Save(); Debug::Text('Company ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Company!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }