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_pagecode: Unique public code for the packagetitle,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 pagesNTSTripSnippet.java: Entity for trip snippetsNTSTripSkeleton.java: Entity for skeleton templatesNTSTripSnippetFile.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¶
- Navigate to:
https://yourserver/tqweb-adm/offerman.html - The page displays two main panels:
- Left panel: Trip Pages list
- Right panel: Trip Snippets list
Managing Trip Pages¶
- Create a New Page:
- Click the "New Page" button
- Enter the HTML filename (e.g., "dubai-packages.html")
- Enter a description
-
Click "Save"
-
Edit a Page:
- Click the edit (pencil) icon next to a page
- Modify the details
-
Click "Save"
-
Delete a Page:
- Click the delete (X) icon next to a page
- Confirm the deletion
-
Note: This will also delete all associated snippets
-
Select a Page:
- Click on any row in the pages table
- The snippets panel will update to show snippets for that page
Managing Trip Snippets¶
- Create a New Snippet:
- Select a page first
- Click the "New Snippet" button
- Fill in all snippet details:
- Package Code (unique identifier)
- Title and Description
- Price, Images, Taglines
- Inclusions HTML
- Chat Request Description
- Active Status
-
Click "Save"
-
Edit a Snippet:
- Click the edit icon next to a snippet
- Modify the details
-
Click "Save"
-
Delete a Snippet:
- Click the delete icon next to a snippet
- Confirm the deletion
Generating HTML Pages¶
- Setup:
- Ensure skeleton templates are configured in
nts.trip_skeleton -
Ensure snippet templates are configured in
nts.trip_snippet_file -
Generate:
- Select a trip page
- Choose a skeleton template from the dropdown
- Choose a snippet template from the dropdown
- Click "Generate & Download"
- 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¶
-
Pagination: Both pages and snippets use page-based pagination with configurable page size (default: 10)
-
Master-Detail: Selecting a page automatically loads its snippets
-
Entity Management: Uses the TQCOMMON EntityFacade for database operations
-
Session Management: All API calls include session tokens for authentication
-
Error Handling: User-friendly notifications for all operations
-
File Generation: HTML is generated server-side and downloaded via blob URLs
Extension Points¶
Adding New Placeholders¶
- Add the field to
NTSTripSnippet.java - Update the database schema
- Add the placeholder replacement in
TripOfferApi.doGeneratePage() - Update the frontend form in
offerman.html
Custom Templates¶
- Create HTML skeleton files with the marker
---INSERT SNIPPETS HERE--- - Create snippet template files with desired placeholders
- Register them in the database tables
- 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_idandcodecolumns 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