' . esc_html__( 'Customers', 'bookingistic' ) . '

'; if ( empty( $result['items'] ) ) { echo '

' . esc_html__( 'No customers yet.', 'bookingistic' ) . '

'; return; } echo ''; foreach ( $result['items'] as $c ) { $view_url = admin_url( 'admin.php?page=bookingistic-customers&view=' . (int) $c['id'] ); echo ''; } echo '
' . esc_html__( 'Name', 'bookingistic' ) . ' ' . esc_html__( 'Email', 'bookingistic' ) . ' ' . esc_html__( 'Phone', 'bookingistic' ) . ' ' . esc_html__( 'Source', 'bookingistic' ) . ' ' . esc_html__( 'Created', 'bookingistic' ) . '
' . esc_html( $c['full_name'] ?: trim( $c['first_name'] . ' ' . $c['last_name'] ) ) . ' ' . esc_html( $c['email'] ) . ' ' . esc_html( $c['phone'] ) . ' ' . esc_html( $c['source'] ) . ' ' . esc_html( $c['created_at'] ) . ' ' . esc_html__( 'Open', 'bookingistic' ) . '
'; } private static function render_detail( int $id ): void { $customer = Customer_Repository::find( $id ); if ( ! $customer ) { echo '

' . esc_html__( 'Customer not found.', 'bookingistic' ) . '

'; return; } $result = Booking_Repository::query( [ 'customer_id' => $id, 'per_page' => 100, 'order' => 'DESC', 'orderby' => 'created_at' ] ); $bookings = $result['items']; $stats = [ 'total' => count( $bookings ), 'pending' => 0, 'confirmed' => 0, 'completed' => 0, 'cancelled' => 0, 'revenue' => 0.0, ]; foreach ( $bookings as $b ) { if ( isset( $stats[ $b['status'] ] ) ) { $stats[ $b['status'] ]++; } if ( in_array( $b['payment_status'], [ 'paid', 'deposit_paid' ], true ) ) { $stats['revenue'] += (float) $b['payment_amount']; } } include BOOKINGISTIC_DIR . 'templates/admin/customer-detail.php'; } }