Appearance
Internal Notes
Flow ID: AD-40 | Module(s): eshop | Complexity: Low Last Updated: 2026-04-04
Business Context
Internal notes provide a simple annotation system that allows admin users to attach free-text notes to various entities (orders, customers, products). Notes are used for internal communication between team members and are never visible to storefront customers.
Each note records the admin user who created it, the entity type and ID it relates to, and a timestamp. Notes are displayed chronologically (newest first) within the context of their parent entity's admin page.
API Reference
REST Endpoints
No REST API. Internal notes are managed exclusively through legacy AJAX endpoints.
Legacy Admin Routes
| Route | Controller | Method | HTTP | Description |
|---|---|---|---|---|
notes/addNewNote | Adv_eshop_notes | addNewNote | POST | Create a new note (AJAX, returns JSON) |
notes/deleteNote/{id} | Adv_eshop_notes | deleteNote | GET | Delete a note by ID (returns bool) |
notes/deleteSingleNote/{id} | Adv_eshop_notes | deleteSingleNote | GET | Delete and redirect back with flash message |
notes/editNotes | Adv_eshop_notes | editNotes | POST | Update a note's text (AJAX, returns JSON) |
Code Flow
Adding a Note
- Admin is on an entity detail page (order, customer, or product).
- The entity page includes a notes panel with an AJAX form.
- POST to
notes/addNewNotewith{ entity_type, entity_id, note }. Adv_eshop_notes::addNewNote()validates the note is not empty.- Builds the record:
entity_type,entity_id,user_id(from session$_SESSION['uid']),note_text,entry_date. - Calls
eshop_notes_model::addNewNote()which inserts intoshop_notes. - Returns JSON with the new note data including formatted
entry_date.
Editing a Note
- POST to
notes/editNoteswith{ entity_id (note ID), note }. editNotes()callseshop_notes_model::updateNote()which updatesnote_textandentry_dateto current timestamp.- Returns the updated note object as JSON.
Deleting a Note
deleteNote($id): Direct delete, returns boolean result (used by AJAX callers).deleteSingleNote($id): Deletes and sets a flash message, then redirects back to the referrer page. Used by non-AJAX delete buttons.
Retrieving Notes (Model Methods)
The model provides entity-specific retrieval methods called by entity admin controllers:
getCustomerNotes($entityId, $limit)-- filtered byentity_type = 'customer'getProductNotes($id, $limit)-- filtered byentity_type = 'product'getOrderNotes($id, $limit)-- filtered byentity_type = 'order'getNotes($userId, $conditions, $limit, $offset)-- general query with search/filter support
Domain Layer
No modern domain layer. Notes are managed entirely through the legacy model.
Architecture
| Component | Path | Purpose |
|---|---|---|
Adv_eshop_notes | ecommercen/eshop/controllers/Adv_eshop_notes.php | Admin controller (81 lines) |
Adv_eshop_notes_model | ecommercen/eshop/models/Adv_eshop_notes_model.php | Model with CRUD + entity-scoped queries (113 lines) |
Eshop_notes_model | application/modules/eshop/models/Eshop_notes_model.php | App-level wrapper |
| Routes | application/config/routes.php:603-604 | notes/(.+) -> eshop/eshop_notes/$1 |
Data Model
shop_notes
| Column | Type | Description |
|---|---|---|
id | int (PK) | Auto-increment primary key |
entity_type | varchar | Entity type: customer, product, order |
entity_id | int | ID of the related entity |
user_id | int | Admin user ID who created the note |
note_text | text | Free-text note content |
entry_date | datetime | Creation/last-edit timestamp |
Configuration
No registry keys or config files. Access is controlled by role-based authorization.
Required roles: AUTH_ROLE_ADVISABLE, AUTH_ROLE_ADMIN, AUTH_ROLE_ORDERS, AUTH_ROLE_CMS.
Client Extension Points
- Override model: Extend
Eshop_notes_modelinapplication/modules/eshop/models/to add custom note types or retrieval logic. - Override controller: Extend
Eshop_notesinapplication/modules/eshop/controllers/to add custom validation or permissions.
Business Rules
- Empty note prevention:
addNewNote()only inserts if thenotePOST field is non-empty. - Entity polymorphism: Notes are polymorphic via
entity_type+entity_id-- no FK constraints. - Timestamp on edit: Editing a note updates its
entry_dateto the current time, so it appears as the most recent action. - Session-based user tracking: The
user_idis read directly from$_SESSION['uid'](not from CI session). - No cascading deletes: Deleting a parent entity (order, customer, product) does not automatically remove its notes.
Related Flows
- AD-03 Order Management Admin -- Order detail page includes notes panel
- AD-04 Customer Management Admin -- Customer detail page includes notes panel
- AD-02 Product Management Admin -- Product admin page includes notes panel