>, error?: string} */ public function search(string $query): array { $query = trim($query); if ($query === '') { return ['status' => 'empty', 'results' => []]; } if (mb_strlen($query) < self::MIN_QUERY_LENGTH) { return ['status' => 'too_short', 'results' => []]; } if (!$this->settingsGateway->isConfigured()) { return ['status' => 'not_configured', 'results' => [], 'error' => 'BC connection not configured']; } try { $results = $this->bcODataGateway->searchCustomers($query); } catch (\Throwable $e) { return ['status' => 'error', 'results' => [], 'error' => 'BC connection failed']; } if ($results === []) { return ['status' => 'no_results', 'results' => []]; } return ['status' => 'success', 'results' => $results]; } /** * Build grid data for the helpdesk debtor list. * * @param array $filters * @return array{status: string, rows: array>, total: int, error?: string} */ public function listForGrid(array $filters): array { if (!$this->settingsGateway->isConfigured()) { return [ 'status' => 'not_configured', 'rows' => [], 'total' => 0, 'error' => 'BC connection not configured', ]; } $search = trim((string) ($filters['search'] ?? '')); $city = trim((string) ($filters['city'] ?? '')); $limit = (int) ($filters['limit'] ?? 10); $offset = (int) ($filters['offset'] ?? 0); $order = (string) ($filters['order'] ?? 'Name'); $dir = (string) ($filters['dir'] ?? 'asc'); if ($limit < 1) { $limit = 1; } elseif ($limit > 100) { $limit = 100; } if ($offset < 0) { $offset = 0; } try { $result = $this->bcODataGateway->listCustomers($search, $city, $limit, $offset, $order, $dir); } catch (\Throwable) { return [ 'status' => 'error', 'rows' => [], 'total' => 0, 'error' => 'BC connection failed', ]; } return [ 'status' => 'success', 'rows' => (array) $result['rows'], 'total' => max(0, (int) $result['total']), ]; } }