/** * Update last owner and operator for the fleet * @since Version 3.9.1 * @return void * @param \Railpage\Locos\LocoClass $Class */ public static function updateFleet_OwnerOperator(LocoClass $Class) { $Database = (new AppCore())->getDatabaseConnection(); $members = $Class->members(); foreach ($members['locos'] as $row) { $Loco = LocosFactory::CreateLocomotive($row['loco_id']); $query = "(SELECT operator_id AS owner_id, link_type FROM loco_org_link WHERE loco_id = ? AND link_type = 1 ORDER BY link_weight DESC LIMIT 0,1)\r\nUNION ALL\r\n(SELECT operator_id, link_type FROM loco_org_link WHERE loco_id = ? AND link_type = 2 ORDER BY link_weight DESC LIMIT 0,1)"; $result = $Database->fetchAll($query, array($Loco->id, $Loco->id)); #$commit = false; foreach ($result as $row) { #printArray($row['organisation_id']); printArray($Loco->owner_id); die; if ($row['link_type_id'] == 1) { $Loco->owner_id = $row['operator_id']; #$commit = true; } if ($row['link_type_id'] == 2) { $Loco->operator_id = $row['operator_id']; #$commit = true; } } #if ($commit) { $Loco->commit(); #} #break; } $Class->flushMemcached(); return; }
/** * Get previous locomotive * @since Version 3.8.7 * @return \Railpage\Locos\Locomotive */ public function previous() { $members = $this->Class->members(); // Get the next loco in this class if ($members['stat'] == "ok") { $break = false; $members['locos'] = array_reverse($members['locos']); foreach ($members['locos'] as $row) { if ($break == true) { return new Locomotive($row['loco_id']); } if ($row['loco_id'] == $this->id) { $break = true; } } } }