/** * @param PersonCollection $personCollection * @param array $tableConfiguration * @return float|int */ private function getHappinessPointsByTableConfiguration(PersonCollection $personCollection, array $tableConfiguration) { $lastKey = $personCollection->getNbPersons() - 1; $totalHappiness = 0; foreach ($tableConfiguration as $key => $personName) { $leftNeighborName = $key > 0 ? $tableConfiguration[$key - 1] : $tableConfiguration[$lastKey]; $rightNeighborName = $key < $lastKey ? $tableConfiguration[$key + 1] : $tableConfiguration[0]; $totalHappiness += $personCollection->getHappinessPoints($personName, $leftNeighborName); $totalHappiness += $personCollection->getHappinessPoints($personName, $rightNeighborName); } return $totalHappiness; }
function getallids() { $personoverview = new PersonCollection($this->_templateobject); $sh = new SearchHandler($personoverview, false); $sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID)); $sh->AddConstraint(new Constraint('usernameaccess', '=', EGS_USERNAME)); $sh->setLimit(1); $return = $personoverview->load($sh); echo json_encode($return); exit; }
public function getPeople($id = '') { if (!empty($id)) { $customer = DataObjectFactory::Factory('SLCustomer'); $customer->load($id); $people = new PersonCollection(); $sh = new SearchHandler($people, false); $sh->addConstraint(new Constraint('company_id', '=', $customer->company_id)); $sh->setFields(array('id', 'name')); $sh->setOrderby('name'); $people->load($sh); $list = array('' => 'None'); $list += $people->getAssoc(); return $list; } else { return array('' => 'None'); } }