function setStation($source, $station, $description = NULL, $type = 'PHONE') { Debug::text('Setting Station: (' . $station . ') Source: ' . $source . ' Description: ' . $description . ' Type: ' . $type, __FILE__, __LINE__, __METHOD__, 10); if ($type == '') { return FALSE; } //Make sure we don't strtolower() type, as it will cause the lookup to fail. $type = trim($type); //We using SOAP, we always have the IP address, always set it unless we're using //the phone punch in. if (strtolower($type) == 'phone' or $type == 20) { $source = Misc::parseCallerID($source); $station = Misc::parseCallerID($station); Debug::text('Filtered Source: ' . $source . ' Station: ' . $station, __FILE__, __LINE__, __METHOD__, 10); } else { $source = $_SERVER['REMOTE_ADDR']; } if ($source == '') { $source = 'Unavailable'; } if ($description == '') { $description = 'N/A'; } if ($source == '') { $source = NULL; } $slf = new StationListFactory(); $slf->getByStationIdandCompanyId($station, $this->getCompanyObject()->getId()); $current_station = $slf->getCurrent(); unset($slf); if ($current_station->isNew()) { Debug::text('Station not found... Adding new one...', __FILE__, __LINE__, __METHOD__, 10); $sf = new StationFactory(); $sf->setCompany($this->getCompanyObject()->getId()); $sf->setStatus('ENABLED'); $sf->setType($type); //If this is a new iButton,Fingerprint, or Barcode station, default to 'ANY' for the source, so we aren't restricted by IP. if (in_array($sf->getType(), array(30, 40, 50))) { $sf->setSource('ANY'); } else { $sf->setSource($source); } $sf->setStation($station); $sf->setDescription($description); //If this is a new iButton,Fingerprint, or Barcode station, default to allow all employees. if (in_array($sf->getType(), array(30, 40, 50))) { $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); } if ($sf->isValid()) { if ($sf->Save(FALSE)) { //return $source; return $sf->getStation(); } } } else { Debug::text('Station FOUND!', __FILE__, __LINE__, __METHOD__, 10); return $current_station->getStation(); } return FALSE; }