getVersion(), __FILE__, __LINE__, __METHOD__, 9 ); return true; } /** * @return bool */ function postInstall() { Debug::text( 'postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9 ); $clf = TTnew( 'CompanyListFactory' ); /** @var CompanyListFactory $clf */ $clf->StartTransaction(); $clf->getAll(); if ( $clf->getRecordCount() > 0 ) { foreach ( $clf as $c_obj ) { if ( $c_obj->getStatus() == 10 ) { $ulf = TTnew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $ulf->getHighestEmployeeNumberByCompanyId( $c_obj->getId() ); if ( $ulf->getRecordCount() > 0 ) { $next_available_employee_number = ( $ulf->getCurrent()->getEmployeeNumber() + 1 ); } else { $next_available_employee_number = 1; } $ulf->getByCompanyId( $c_obj->getId(), null, null, null, [ 'hire_date' => 'asc' ] ); if ( $ulf->getRecordCount() > 0 ) { foreach ( $ulf as $u_obj ) { if ( $u_obj->getEmployeeNumber() == '' ) { Debug::text( 'Setting Employee Number to: ' . $next_available_employee_number . ' for ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9 ); $u_obj->setEmployeeNumber( $next_available_employee_number ); if ( $u_obj->isValid() ) { $u_obj->Save(); $next_available_employee_number++; } } else { Debug::text( 'NOT Setting Employee Number for ' . $u_obj->getUserName() . ' already set to: ' . $u_obj->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 9 ); } } } } } } //$clf->FailTransaction(); $clf->CommitTransaction(); return true; } } ?>