Skip to content

Offer Management Implementation

Overview

The Trip Offer Management system provides a comprehensive interface for managing destination trip pages, trip variant snippets, and automated HTML page generation. This system enables creating, editing, and managing trip packages that can be dynamically assembled into complete HTML pages.

Components

1. Database Schema

Located in: doc/trip_offer_schema.sql

The system uses four main tables in the nts schema:

  • nts.trip_page: Stores destination pages
  • page_id: Unique identifier (sequence-managed)
  • page_name: HTML filename (e.g., "dubai-packages.html")
  • page_desc: Description of the destination

  • nts.trip_snippet: Stores trip variant snippets

  • snippet_id: Unique identifier (sequence-managed)
  • page_id: Foreign key to trip_page
  • code: Unique public code for the package
  • title, description, price, etc.: Package details
  • active: Status indicator (1=active, 0=inactive)

  • nts.trip_skeleton: Stores HTML skeleton templates

  • Contains the base HTML structure with a marker ---INSERT SNIPPETS HERE---

  • nts.trip_snippet_file: Stores snippet templates

  • Contains HTML fragments with placeholders like %%title%%, %%price%%, etc.

2. Backend Components

Entity Classes

Located in: tqapp/src/main/java/com/perun/tlinq/client/nts/entity/trip/

  • NTSTripPage.java: Entity for trip pages
  • NTSTripSnippet.java: Entity for trip snippets
  • NTSTripSkeleton.java: Entity for skeleton templates
  • NTSTripSnippetFile.java: Entity for snippet templates

API Endpoints

Located in: tqapi/src/main/java/com/perun/tlinq/api/TripOfferApi.java

Trip Page APIs: - POST /api/tripoffer/page/list - List all pages (with pagination) - POST /api/tripoffer/page/read - Read a single page - POST /api/tripoffer/page/write - Create or update a page - POST /api/tripoffer/page/delete - Delete a page

Trip Snippet APIs: - POST /api/tripoffer/snippet/list - List snippets for a page (with pagination) - POST /api/tripoffer/snippet/read - Read a single snippet - POST /api/tripoffer/snippet/write - Create or update a snippet - POST /api/tripoffer/snippet/delete - Delete a snippet

Supporting APIs: - POST /api/tripoffer/skeleton/list - List available skeleton templates - POST /api/tripoffer/snippetfile/list - List available snippet templates - POST /api/tripoffer/page/generate - Generate HTML page with snippets

3. Frontend Components

HTML Page

Located in: tqweb-adm/offerman.html

Features: - Master-detail layout (pages on left 1/3, snippets on right 2/3) - Paginated tables for both pages and snippets - Modal dialogs for add/edit operations - HTML generation section with template selection

JavaScript Module

Located in: tqweb-adm/js/modules/offerman.js

Provides: - Data loading and pagination - CRUD operations - Master-detail coordination - HTML generation and download

Usage

Accessing the System

  1. Navigate to: https://yourserver/tqweb-adm/offerman.html
  2. The page displays two main panels:
  3. Left panel: Trip Pages list
  4. Right panel: Trip Snippets list

Managing Trip Pages

  1. Create a New Page:
  2. Click the "New Page" button
  3. Enter the HTML filename (e.g., "dubai-packages.html")
  4. Enter a description
  5. Click "Save"

  6. Edit a Page:

  7. Click the edit (pencil) icon next to a page
  8. Modify the details
  9. Click "Save"

  10. Delete a Page:

  11. Click the delete (X) icon next to a page
  12. Confirm the deletion
  13. Note: This will also delete all associated snippets

  14. Select a Page:

  15. Click on any row in the pages table
  16. The snippets panel will update to show snippets for that page

Managing Trip Snippets

  1. Create a New Snippet:
  2. Select a page first
  3. Click the "New Snippet" button
  4. Fill in all snippet details:
    • Package Code (unique identifier)
    • Title and Description
    • Price, Images, Taglines
    • Inclusions HTML
    • Chat Request Description
    • Active Status
  5. Click "Save"

  6. Edit a Snippet:

  7. Click the edit icon next to a snippet
  8. Modify the details
  9. Click "Save"

  10. Delete a Snippet:

  11. Click the delete icon next to a snippet
  12. Confirm the deletion

Generating HTML Pages

  1. Setup:
  2. Ensure skeleton templates are configured in nts.trip_skeleton
  3. Ensure snippet templates are configured in nts.trip_snippet_file

  4. Generate:

  5. Select a trip page
  6. Choose a skeleton template from the dropdown
  7. Choose a snippet template from the dropdown
  8. Click "Generate & Download"
  9. The system will:
    • Fetch all active snippets for the selected page
    • Generate HTML for each snippet using the template
    • Replace placeholders with actual data
    • Insert all snippets into the skeleton at the marker
    • Download the complete HTML file

Placeholder System

The snippet template can use these placeholders: - %%image%% - Image URL - %%imagetitle%% - Image alt text - %%tagline1%% - First tagline - %%tagline2%% - Second tagline - %%title%% - Package title - %%shortdesc%% - Short description - %%price%% - Price display - %%description%% - Full description - %%inclusionhtml%% - HTML list of inclusions - %%code%% - Package code (for links) - %%request_desc%% - Chat request description

Design Pattern

The system follows the established design language of the TQPRO admin interface:

  • Color Scheme: Purple primary (#362c5d), orange secondary (#FFC166)
  • Layout: Foundation CSS grid system
  • Components: Cards, tables, modals following established patterns
  • Icons: Foundation Icons (fi-) for consistency
  • Interactions: Smooth transitions, hover effects, status badges

Technical Notes

  1. Pagination: Both pages and snippets use page-based pagination with configurable page size (default: 10)

  2. Master-Detail: Selecting a page automatically loads its snippets

  3. Entity Management: Uses the TQCOMMON EntityFacade for database operations

  4. Session Management: All API calls include session tokens for authentication

  5. Error Handling: User-friendly notifications for all operations

  6. File Generation: HTML is generated server-side and downloaded via blob URLs

Extension Points

Adding New Placeholders

  1. Add the field to NTSTripSnippet.java
  2. Update the database schema
  3. Add the placeholder replacement in TripOfferApi.doGeneratePage()
  4. Update the frontend form in offerman.html

Custom Templates

  1. Create HTML skeleton files with the marker ---INSERT SNIPPETS HERE---
  2. Create snippet template files with desired placeholders
  3. Register them in the database tables
  4. They will appear in the generation dropdowns

Maintenance

Database Backups

Regularly backup these tables: - nts.trip_page - nts.trip_snippet - nts.trip_skeleton - nts.trip_snippet_file

Performance

  • Pagination limits memory usage
  • Indexes on page_id and code columns ensure fast lookups
  • Active status filtering reduces unnecessary data loading

Troubleshooting

Problem: Snippets not loading - Solution: Ensure a page is selected first

Problem: Generation fails - Solution: Check that skeleton and snippet file paths are correct and files exist

Problem: Placeholders not replaced - Solution: Verify placeholder names match exactly (case-sensitive)

Problem: API errors - Solution: Check server logs for detailed error messages

Support

For issues or questions: - Check server logs in tqapi module - Verify database connectivity - Ensure all required tables exist - Contact development team

License

Copyright (c) 2024. Perun Consulting Services FZ LLE