getTraceAsString(); } sendError("Unable to load client list from InvoiceNinja server:\n" . $ex->getMessage()); } class Clients { public static function getAll(): array { $clients = NinjaClient::all(); $list = []; foreach ($clients as $client) { $name = $client->name; if (empty($name)) { $name = $client->contacts[0]->first_name . " " . $client->contacts[0]->last_name; } $list[] = new Client($client->id, $name); } return $list; } public static function getClient($id): Client { $client = NinjaClient::find($id); return new Client($client->id, $client->name); } } } else { // Use internal client table class Clients { public static function getAll(): array { global $database; $clients = $database->select("clients", ["clientid", "name"]); $list = []; foreach ($clients as $client) { $list[] = new Client($client['clientid'], $client['name']); } return $list; } public static function getClient($id): Client { global $database; $client = $database->get("clients", ["clientid", "name"], ["clientid" => $id]); return new Client($client['clientid'], $client['name']); } } }