function getCountryPrimaryCurrencyID() { $iso_code = $this->getCountryPrimaryCurrency(); //ISO Code if ($iso_code != '' and is_numeric($this->getCompany())) { $clf = new CurrencyListFactory(); $clf->getByCompanyIdAndISOCode($this->getCompany(), $iso_code); if ($clf->getRecordCount() > 0) { $currency_id = $clf->getCurrent()->getId(); //Debug::Text('Country Primary Currency ID: '. $currency_id , __FILE__, __LINE__, __METHOD__, 10 ); return $currency_id; } } Debug::Text('Country Primary Currency does not exist: ' . $iso_code, __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
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) { $uf = new 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 = new 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); } } $hire_date = strtotime(rand(2000, 2005) . '-' . rand(1, 12) . '-' . rand(1, 28)); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); break; case 40: //John Hancock $uf->setUserName('john.hancock' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '2222' ); //$uf->setPhonePassword( '2222' ); $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); break; case 100: //Administrator $uf->setUserName('demoadmin' . $this->getUserNamePostfix()); $uf->setPassword('demo'); //$uf->setPhoneId( '3333' ); //$uf->setPhonePassword( '3333' ); $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); 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); } 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); } 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', strtotime('01-Jun-04')); $this->createUserWage($insert_id, '20.15', strtotime('01-Jan-05')); $this->createUserWage($insert_id, '21.50', strtotime('01-Jan-06')); $this->createUserWage($insert_id, '10.00', strtotime('01-Jan-04'), $this->user_wage_groups[0]); $this->createUserWage($insert_id, '20.00', strtotime('01-Jan-04'), $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; }
$filter_data['src_department_options'] = Misc::arrayDiffByKey((array) $filter_data['department_ids'], $department_options); $filter_data['selected_department_options'] = Misc::arrayIntersectByKey((array) $filter_data['department_ids'], $department_options); //Get employee titles $utlf = new UserTitleListFactory(); $utlf->getByCompanyId($current_company->getId()); $user_title_options = Misc::prependArray($all_array_option, $utlf->getArrayByListFactory($utlf, FALSE, TRUE)); $filter_data['src_user_title_options'] = Misc::arrayDiffByKey((array) $filter_data['user_title_ids'], $user_title_options); $filter_data['selected_user_title_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_title_ids'], $user_title_options); //Get pay periods $pplf = new PayPeriodListFactory(); $pplf->getByCompanyId($current_company->getId()); $pay_period_options = Misc::prependArray($all_array_option, $pplf->getArrayByListFactory($pplf, FALSE, TRUE)); $filter_data['src_pay_period_options'] = Misc::arrayDiffByKey((array) $filter_data['pay_period_ids'], $pay_period_options); $filter_data['selected_pay_period_options'] = Misc::arrayIntersectByKey((array) $filter_data['pay_period_ids'], $pay_period_options); //Get currencies $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($current_company->getId()); $currency_options = Misc::prependArray($all_array_option, $crlf->getArrayByListFactory($crlf, FALSE, TRUE)); $filter_data['src_currency_options'] = Misc::arrayDiffByKey((array) $filter_data['currency_ids'], $currency_options); $filter_data['selected_currency_options'] = Misc::arrayIntersectByKey((array) $filter_data['currency_ids'], $currency_options); //Get column list $filter_data['src_column_options'] = Misc::arrayDiffByKey((array) $filter_data['column_ids'], $columns); $filter_data['selected_column_options'] = Misc::arrayIntersectByKey((array) $filter_data['column_ids'], $columns); //Get primary/secondary order list $filter_data['sort_options'] = $columns; //$filter_data['sort_options']['effective_date_order'] = 'Wage Effective Date'; unset($filter_data['sort_options']['effective_date']); $filter_data['sort_direction_options'] = Misc::getSortDirectionArray(); $filter_data['group_by_options'] = Misc::prependArray(array('0' => TTi18n::gettext('No Grouping')), $static_columns); $filter_data['export_type_options'] = array('csv' => TTi18n::gettext('CSV (Excel)'), 'simply' => TTi18n::gettext('Simply Accounting GL')); $saved_report_options = $ugdlf->getByUserIdAndScriptArray($current_user->getId(), $_SERVER['SCRIPT_NAME']);
function setCurrency($id) { $id = trim($id); Debug::Text('Currency ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $culf = new CurrencyListFactory(); if ($this->Validator->isResultSetWithRows('currency', $culf->getByID($id), TTi18n::gettext('Invalid Currency'))) { $this->data['currency_id'] = $id; return TRUE; } return FALSE; }
if (isset($ids) and is_array($ids)) { foreach ($ids as $id) { $clf->getByIdAndCompanyId($id, $current_company->getId()); foreach ($clf as $c_obj) { $c_obj->setDeleted($delete); if ($c_obj->isValid()) { $c_obj->Save(); } } } } Redirect::Page(URLBuilder::getURL(NULL, 'CurrencyList.php')); break; default: BreadCrumb::setCrumb($title); $clf = new CurrencyListFactory(); $clf->getByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); $pager = new Pager($clf); $iso_code_options = $clf->getISOCodesArray(); $base_currency = FALSE; foreach ($clf as $c_obj) { if ($c_obj->getBase() === TRUE) { $base_currency = TRUE; } $rows[] = array('id' => $c_obj->GetId(), 'status_id' => $c_obj->getStatus(), 'name' => $c_obj->getName(), 'iso_code' => $c_obj->getISOCode(), 'currency_name' => Option::getByKey($c_obj->getISOCode(), $iso_code_options), 'conversion_rate' => $c_obj->getConversionRate(), 'auto_update' => $c_obj->getAutoUpdate(), 'is_base' => $c_obj->getBase(), 'is_default' => $c_obj->getDefault(), 'deleted' => $c_obj->getDeleted()); } $smarty->assign_by_ref('currencies', $rows); $smarty->assign_by_ref('base_currency', $base_currency); $smarty->assign_by_ref('sort_column', $sort_column); $smarty->assign_by_ref('sort_order', $sort_order); $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
$pclf->getByCompanyId($current_company->getId()); $permission_control_options = $pclf->getArrayByListFactory($pclf, TRUE); $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_options = $ppslf->getByCompanyIDArray($current_company->getId()); $pglf = new PolicyGroupListFactory(); $policy_group_options = $pglf->getByCompanyIDArray($current_company->getId()); $pclf = new PermissionControlListFactory(); $pclf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $permission_control_user_map = $pclf->getUserToPermissionControlMapArrayByListFactory($pclf); $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $pay_period_schedule_user_map = $ppslf->getUserToPayPeriodScheduleMapArrayByListFactory($ppslf); $pglf = new PolicyGroupListFactory(); $pglf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $policy_group_user_map = $pglf->getUserToPolicyGroupMapArrayByListFactory($pglf); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($current_company->getId()); $currency_options = $crlf->getArrayByListFactory($crlf, FALSE, TRUE); $upf = new UserPreferenceFactory(); $language_options = TTi18n::getLanguageArray(); $date_format_options = $upf->getOptions('date_format'); $time_format_options = $upf->getOptions('time_format'); $time_unit_format_options = $upf->getOptions('time_unit_format'); $timesheet_view_options = $upf->getOptions('timesheet_view'); $start_week_day_options = $upf->getOptions('start_week_day'); $time_zone_options = $upf->getOptions('time_zone'); $uwlf = new UserWageListFactory(); $uwlf->getLastWageByUserIdAndDate($filter_data['user_ids'], TTDate::getTime()); if ($uwlf->getRecordCount() > 0) { foreach ($uwlf as $uw_obj) { $user_wage[$uw_obj->getUser()] = array('type_id' => $uw_obj->getType(), 'type' => Option::getByKey($uw_obj->getType(), $uw_obj->getOptions('type')), 'wage' => $uw_obj->getWage(), 'effective_date' => $uw_obj->getEffectiveDate());
function postSave() { $this->removeCache($this->getId()); $this->remoteSave(); if ($this->getDeleted() == FALSE) { //Add base currency for this new company. if ($this->getEnableAddCurrency() == TRUE) { $clf = new CurrencyListFactory(); $clf->getByCompanyId($this->getId()); if ($clf->getRecordCount() == 0) { Debug::text('Adding Default Currency', __FILE__, __LINE__, __METHOD__, 9); $cf = new CurrencyFactory(); $country_to_currency_map_arr = $cf->getOptions('country_currency'); if (isset($country_to_currency_map_arr[$this->getCountry()])) { $base_currency = $country_to_currency_map_arr[$this->getCountry()]; Debug::text('Found Base Currency For Country: ' . $this->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9); } else { Debug::text('DID NOT Find Base Currency For Country: ' . $this->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9); $base_currency = 'USD'; } $cf->setCompany($this->getId()); $cf->setStatus(10); $cf->setName($base_currency); $cf->setISOCode($base_currency); $cf->setConversionRate('1.000000000'); $cf->setAutoUpdate(FALSE); $cf->setBase(TRUE); $cf->setDefault(TRUE); if ($cf->isValid()) { $cf->Save(); } } } if ($this->getEnableAddPermissionGroupPreset() == TRUE) { Debug::text('Adding Preset Permission Groups', __FILE__, __LINE__, __METHOD__, 9); $pf = new PermissionFactory(); $pf->StartTransaction(); if ($this->getProductEdition() == 20) { $preset_flags = array('job' => 1, 'invoice' => 1, 'document' => 1); } else { $preset_flags = array(); } $preset_options = $pf->getOptions('preset'); foreach ($preset_options as $preset_id => $preset_name) { $pcf = new PermissionControlFactory(); $pcf->setCompany($this->getId()); $pcf->setName($preset_name); $pcf->setDescription(''); if ($pcf->isValid()) { $pcf_id = $pcf->Save(FALSE); $pf->applyPreset($pcf_id, $preset_id, $preset_flags); } } //$pf->FailTransaction(); $pf->CommitTransaction(); } if ($this->getEnableAddStation() == TRUE) { Debug::text('Adding Default Station', __FILE__, __LINE__, __METHOD__, 9); //Enable punching in from all stations $sf = new StationFactory(); $sf->setCompany($this->getId()); $sf->setStatus(20); $sf->setType(10); $sf->setSource('ANY'); $sf->setStation('ANY'); $sf->setDescription('All stations'); $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); if ($sf->isValid()) { $sf->Save(); } } if ($this->getEnableAddPayStubEntryAccountPreset() == TRUE) { Debug::text('Adding Pay Stub Entry Account Presets', __FILE__, __LINE__, __METHOD__, 9); PayStubEntryAccountFactory::addPresets($this->getId()); } if ($this->getEnableAddCompanyDeductionPreset() == TRUE) { Debug::text('Adding Company Deduction Presets', __FILE__, __LINE__, __METHOD__, 9); CompanyDeductionFactory::addPresets($this->getId()); } if ($this->getEnableAddRecurringHolidayPreset() == TRUE) { Debug::text('Adding Recurring Holiday Presets', __FILE__, __LINE__, __METHOD__, 9); RecurringHolidayFactory::addPresets($this->getId(), $this->getCountry()); } } if ($this->getDeleted() == TRUE) { $ulf = new UserListFactory(); $ulf->getByCompanyId($this->getID()); if ($ulf->getRecordCount() > 0) { $ulf->StartTransaction(); foreach ($ulf as $u_obj) { Debug::text('Deleting User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $u_obj->setDeleted(TRUE); if ($u_obj->isValid()) { $u_obj->Save(); } } $ulf->CommitTransaction(); } } return TRUE; }
if (isset($data['is_default']) and $data['is_default'] == 1) { $cf->setDefault(TRUE); } else { $cf->setDefault(FALSE); } $cf->setRateModifyPercent($data['rate_modify_percent']); if ($cf->isValid()) { $cf->Save(); //Redirect::Page( URLBuilder::getURL( array('id' => $data['id'], 'data_saved' => TRUE), 'EditCurrency.php') ); Redirect::Page(URLBuilder::getURL(NULL, 'CurrencyList.php')); break; } default: if (isset($id)) { BreadCrumb::setCrumb($title); $clf = new CurrencyListFactory(); $clf->getByIdAndCompanyId($id, $current_company->getId()); foreach ($clf as $c_obj) { //Debug::Arr($branch,'branch', __FILE__, __LINE__, __METHOD__,10); $data = array('id' => $c_obj->getId(), 'status' => $c_obj->getStatus(), 'name' => $c_obj->getName(), 'iso_code' => $c_obj->getISOCode(), 'conversion_rate' => $c_obj->getConversionRate(), 'auto_update' => $c_obj->getAutoUpdate(), 'rate_modify_percent' => $c_obj->getRateModifyPercent(), 'actual_rate' => (double) $c_obj->getActualRate(), 'actual_rate_updated_date' => $c_obj->getActualRateUpdatedDate(), 'is_base' => $c_obj->getBase(), 'is_default' => $c_obj->getDefault(), 'created_date' => $c_obj->getCreatedDate(), 'created_by' => $c_obj->getCreatedBy(), 'updated_date' => $c_obj->getUpdatedDate(), 'updated_by' => $c_obj->getUpdatedBy(), 'deleted_date' => $c_obj->getDeletedDate(), 'deleted_by' => $c_obj->getDeletedBy()); } } elseif ($action != 'submit') { $data = array('conversion_rate' => '1.0000000000', 'rate_modify_percent' => '1.0000000000'); } //Select box options; $data['status_options'] = $cf->getOptions('status'); $data['iso_code_options'] = $cf->getISOCodesArray(); $smarty->assign_by_ref('data', $data); $smarty->assign_by_ref('data_saved', $data_saved); break; }
function setCurrency($id) { $id = trim($id); Debug::Text('Currency ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $culf = new CurrencyListFactory(); $old_currency_id = $this->getCurrency(); if ($this->Validator->isResultSetWithRows('currency', $culf->getByID($id), TTi18n::gettext('Invalid Currency'))) { $this->data['currency_id'] = $id; if ($culf->getRecordCount() == 1 and ($this->isNew() or $old_currency_id != $id)) { $this->setCurrencyRate($culf->getCurrent()->getReverseConversionRate()); } return TRUE; } return FALSE; }
$user_data['next_available_employee_number'] = NULL; } } else { $user_data['next_available_employee_number'] = 1; } if (!isset($user_data['hire_date']) or $user_data['hire_date'] == '') { $user_data['hire_date'] = time(); } } //var_dump($user_data); //Select box options; $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($company_id); $dlf = new DepartmentListFactory(); $department_options = $dlf->getByCompanyIdArray($company_id); $culf = new CurrencyListFactory(); $culf->getByCompanyId($company_id); $currency_options = $culf->getArrayByListFactory($culf, FALSE, TRUE); $hotf = new HierarchyObjectTypeFactory(); $hierarchy_object_type_options = $hotf->getOptions('object_type'); $hclf = new HierarchyControlListFactory(); $hclf->getObjectTypeAppendedListByCompanyID($company_id); $hierarchy_control_options = $hclf->getArrayByListFactory($hclf, TRUE, TRUE); //Select box options; $user_data['branch_options'] = $branch_options; $user_data['department_options'] = $department_options; $user_data['currency_options'] = $currency_options; $user_data['sex_options'] = $uf->getOptions('sex'); $user_data['status_options'] = $uf->getOptions('status'); $clf = new CompanyListFactory(); $user_data['country_options'] = $clf->getOptions('country');
function getCurrencyData($currency_id) { Debug::Text('Getting Currency Data for ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); $clf = new CurrencyListFactory(); $clf->getById($currency_id); if ($clf->getRecordCount() > 0) { $c_obj = $clf->getCurrent(); $retarr = array('id' => $c_obj->getId(), 'conversion_rate' => $c_obj->getConversionRate(), 'iso_code' => $c_obj->getISOCode()); return $retarr; } return FALSE; }
function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Configure currencies for Standard Edition. if ($this->getIsUpgrade() == TRUE) { $clf = new CompanyListFactory(); $clf->StartTransaction(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() == 10) { //Converting to new Accrual Policy table. Debug::text('Converting to new Accrual Policy Table: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $pglf = new PolicyGroupListFactory(); $pglf->getByCompanyId($c_obj->getId()); if ($pglf->getRecordCount() > 0) { foreach ($pglf as $pg_obj) { Debug::text('Accrual Policy ID: ' . $pg_obj->getColumn('accrual_policy_id'), __FILE__, __LINE__, __METHOD__, 9); if ($pg_obj->getColumn('accrual_policy_id') != '' and $pg_obj->getColumn('accrual_policy_id') != 0) { $pg_obj->setAccrualPolicy(array($pg_obj->getColumn('accrual_policy_id'))); if ($pg_obj->isValid()) { $pg_obj->Save(); } } } } Debug::text('Adding Currency Information to Company: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($c_obj->getId()); if ($crlf->getRecordCount() == 0) { $cf = new CurrencyFactory(); $country_to_currency_map_arr = $cf->getOptions('country_currency'); if (isset($country_to_currency_map_arr[$c_obj->getCountry()])) { $base_currency = $country_to_currency_map_arr[$c_obj->getCountry()]; Debug::text('Found Base Currency For Country: ' . $c_obj->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9); } else { Debug::text('DID NOT Find Base Currency For Country: ' . $c_obj->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9); $base_currency = 'USD'; } $cf->setCompany($c_obj->getId()); $cf->setStatus(10); $cf->setName($base_currency); $cf->setISOCode($base_currency); $cf->setConversionRate('1.000000000'); $cf->setAutoUpdate(FALSE); $cf->setBase(TRUE); $cf->setDefault(TRUE); if ($cf->isValid()) { $base_currency_id = $cf->Save(); Debug::text('Base Currency ID: ' . $base_currency_id, __FILE__, __LINE__, __METHOD__, 10); //Set Employee Hire Defaults. $udlf = new UserDefaultListFactory(); $udlf->getByCompanyId($c_obj->getId()); if ($udlf->getRecordCount() > 0) { $ud_obj = $udlf->getCurrent(); $ud_obj->setCurrency($base_currency_id); $ud_obj->setLanguage('en'); if ($ud_obj->isValid()) { $ud_obj->Save(); } } unset($udlf, $ud_obj); if (is_numeric($base_currency_id)) { $ulf = new UserListFactory(); $ulf->getByCompanyId($c_obj->getId()); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $u_obj) { $user_id = $u_obj->getID(); Debug::text('Setting Base Currency For User: '******' ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); $u_obj->setCurrency($base_currency_id); if ($u_obj->isValid()) { if ($u_obj->Save() == TRUE) { //Set User Default Language $uplf = new UserPreferenceListFactory(); $uplf->getByUserIDAndCompanyID($user_id, $c_obj->getId()); if ($uplf->getRecordCount() > 0) { $up_obj = $uplf->getCurrent(); $up_obj->setLanguage('en'); //Englist if ($up_obj->isValid()) { $up_obj->Save(); } } unset($uplf, $up_obj); Debug::text(' Setting Base Currency for Pay Stubs, User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); //Change all pay stubs for this user to the base currency. //Do this in a single query for speed purposes. $ph = array('currency_id' => $base_currency_id, 'currency_rate' => '1.000000000', 'user_id' => $user_id); $query = 'update pay_stub set currency_id = ?, currency_rate = ? where user_id = ?'; Debug::text(' Pay Stub Currency Query: ' . $query, __FILE__, __LINE__, __METHOD__, 10); $u_obj->db->Execute($query, $ph); /* $pslf = new PayStubListFactory(); $pslf->getByUserIdAndCompanyId( $user_id, $c_obj->getId() ); if ( $pslf->getRecordCount() > 0 ) { foreach( $pslf as $ps_obj ) { //Debug::text(' Setting Base Currency for Pay Stub ID: '. $ps_obj->getId(), __FILE__, __LINE__, __METHOD__,10); $ps_obj->setCurrency( $base_currency_id ); if ( $ps_obj->isValid() ) { $ps_obj->setEnableLinkedAccruals( FALSE ); $ps_obj->setEnableCalcYTD( FALSE ); $ps_obj->setEnableProcessEntries( FALSE ); $ps_obj->Save(); } unset($ps_obj); } } unset($pslf); */ } else { Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); } unset($u_obj, $user_id); } } unset($ulf); } } unset($cf); } } else { Debug::text('Company is not active! ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); } unset($c_obj, $base_currency, $base_currency_id, $crlf); } } //$clf->FailTransaction(); $clf->CommitTransaction(); } //Add currency updating to cron. $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR; if (PHP_OS == 'WINNT') { $cron_job_base_command = 'php-win.exe ' . $maint_base_path; } else { $cron_job_base_command = 'php ' . $maint_base_path; } Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9); $cjf = new CronJobFactory(); $cjf->setName('UpdateCurrencyRates'); $cjf->setMinute(45); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand($cron_job_base_command . 'UpdateCurrencyRates.php'); $cjf->Save(); return TRUE; }
function getBaseCurrencyHourlyRate($rate) { if ($rate == '') { return FALSE; } $clf = new CurrencyListFactory(); $clf->getByCompanyIdAndBase($this->getUserObject()->getCompany(), TRUE); if ($clf->getRecordCount() > 0) { $base_currency_obj = $clf->getCurrent(); //If current currency is the base currency, just return the rate. if ($base_currency_obj->getId() == $this->getUserObject()->getCurrency()) { return $rate; } else { //Debug::text(' Base Currency Rate: '. $base_currency_obj->getConversionRate() .' Hourly Rate: '. $rate , __FILE__, __LINE__, __METHOD__,10); return CurrencyFactory::convertCurrency($this->getUserObject()->getCurrency(), $base_currency_obj->getId(), $rate); } } return FALSE; }
static function updateCurrencyRates($company_id) { /* Contact info@timetrex.com to request adding custom currency data feeds. */ $base_currency = FALSE; $clf = new CurrencyListFactory(); $clf->getByCompanyId($company_id); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getBase() == TRUE) { $base_currency = $c_obj->getISOCode(); } if ($c_obj->getStatus() == 10 and $c_obj->getAutoUpdate() == TRUE) { $active_currencies[] = $c_obj->getISOCode(); } } } unset($clf, $c_obj); if ($base_currency != FALSE and isset($active_currencies) and is_array($active_currencies) and count($active_currencies) > 0) { $ttsc = new TimeTrexSoapClient(); $currency_rates = $ttsc->getCurrencyExchangeRates($company_id, $active_currencies, $base_currency); } else { Debug::Text('Invalid Currency Data, not getting rates...', __FILE__, __LINE__, __METHOD__, 10); } if (isset($currency_rates) and is_array($currency_rates) and count($currency_rates) > 0) { foreach ($currency_rates as $currency => $rate) { if (is_numeric($rate)) { $clf = new CurrencyListFactory(); $clf->getByCompanyIdAndISOCode($company_id, $currency); if ($clf->getRecordCount() == 1) { $c_obj = $clf->getCurrent(); if ($c_obj->getAutoUpdate() == TRUE) { $c_obj->setActualRate($rate); $c_obj->setConversionRate($c_obj->getPercentModifiedRate($rate)); $c_obj->setActualRateUpdatedDate(time()); if ($c_obj->isValid()) { $c_obj->Save(); } } } } else { Debug::Text('Invalid rate from data feed! Currency: ' . $currency . ' Rate: ' . $rate, __FILE__, __LINE__, __METHOD__, 10); } } return TRUE; } Debug::Text('Updating Currency Data Failed...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }