# pluginsglpi/credit architecture

> Architecture diagram of the GitHub repository pluginsglpi/credit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pluginsglpi/credit
- Repository: https://github.com/pluginsglpi/credit

## Overview

Credit is a GLPI plugin for defining voucher types, assigning vouchers and quantities to entities, recording ticket-related consumption, and reviewing remaining credits and usage. It also supports consumption settings, expiry/low-credit alerts, and ticket notifications. The graph reflects documented capabilities and sampled hook/handler behavior; several subsystem paths are present in the tree but their implementation was not sampled, so uncertain wiring is omitted.

Main entry points: [`inc/entity.class.php`](https://github.com/pluginsglpi/credit/blob/main/inc/entity.class.php) (Entity vouchers), [`inc/ticket.class.php`](https://github.com/pluginsglpi/credit/blob/main/inc/ticket.class.php) (Consumption logic), [`front/entity.form.php`](https://github.com/pluginsglpi/credit/blob/main/front/entity.form.php) (Entity voucher form), [`front/entityconfig.form.php`](https://github.com/pluginsglpi/credit/blob/main/front/entityconfig.form.php) (Entity settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_management["Voucher management"]
  node_entity_form["Entity voucher form<br/>[entity.form.php]"]
  node_entity_config["Entity settings"]
  node_entity_model["Entity vouchers<br/>[entity.class.php]"]
  node_type_model["Voucher types<br/>[type.class.php]"]
  node_config_model["Ticket settings"]
end

subgraph group_consumption["Ticket consumption"]
  node_ticket_form["Ticket voucher form<br/>[ticket.form.php]"]
  node_ticket_model["Consumption logic<br/>[ticket.class.php]"]
  node_quantity_ajax["Available quantity lookup"]
  node_browser_script["Form field updates<br/>[credit.js]"]
end

subgraph group_visibility["Usage visibility"]
  node_ticket_page["Consumption details<br/>[ticket.php]"]
  node_notification_hook["Ticket notification data<br/>[hook.php]"]
end

subgraph group_alerts["Alerts and notifications"]
  node_entity_template["Entity alert templates"]
end

node_user(("GLPI user"))
node_glpi["GLPI runtime"]
node_db[("GLPI database")]

node_user -->|"uses"| node_glpi
node_glpi -->|"handles entity edits"| node_entity_form
node_entity_form -->|"creates or updates"| node_entity_model
node_entity_model -->|"stores vouchers"| node_db
node_glpi -->|"handles settings"| node_entity_config
node_entity_config -->|"updates settings"| node_config_model
node_config_model -->|"stores settings"| node_db
node_glpi -->|"manages dropdown types"| node_type_model
node_type_model -->|"stores types"| node_db
node_glpi -->|"handles consumption entry"| node_ticket_form
node_ticket_form -->|"adds consumption"| node_ticket_model
node_ticket_model -->|"reads and records use"| node_db
node_glpi -->|"dispatches ticket hooks"| node_ticket_model
node_ticket_model -->|"checks voucher balance"| node_entity_model
node_glpi -->|"requests quantity"| node_quantity_ajax
node_quantity_ajax -->|"gets available maximum"| node_entity_model
node_glpi -->|"loads form behavior"| node_browser_script
node_browser_script -->|"updates ticket selections"| node_glpi
node_glpi -->|"opens consumption view"| node_ticket_page
node_ticket_page -->|"loads consumed details"| node_ticket_model
node_glpi -->|"builds ticket notification data"| node_notification_hook
node_notification_hook -->|"reads voucher totals"| node_db
node_glpi -->|"runs credit checks"| node_entity_model
node_entity_model -->|"raises expiry or low-credit event"| node_entity_template
node_entity_template -->|"provides notification content"| node_glpi

click node_entity_form "https://github.com/pluginsglpi/credit/blob/main/front/entity.form.php"
click node_entity_config "https://github.com/pluginsglpi/credit/blob/main/front/entityconfig.form.php"
click node_entity_model "https://github.com/pluginsglpi/credit/blob/main/inc/entity.class.php"
click node_type_model "https://github.com/pluginsglpi/credit/blob/main/inc/type.class.php"
click node_config_model "https://github.com/pluginsglpi/credit/blob/main/inc/ticketconfig.class.php"
click node_ticket_form "https://github.com/pluginsglpi/credit/blob/main/front/ticket.form.php"
click node_ticket_model "https://github.com/pluginsglpi/credit/blob/main/inc/ticket.class.php"
click node_ticket_page "https://github.com/pluginsglpi/credit/blob/main/front/ticket.php"
click node_notification_hook "https://github.com/pluginsglpi/credit/blob/main/hook.php"
click node_entity_template "https://github.com/pluginsglpi/credit/blob/main/inc/notificationtargetentity.class.php"
click node_quantity_ajax "https://github.com/pluginsglpi/credit/blob/main/ajax/dropdownQuantity.php"
click node_browser_script "https://github.com/pluginsglpi/credit/blob/main/public/js/credit.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entity_form,node_entity_config,node_entity_model,node_type_model,node_config_model,node_user toneBlue
class node_ticket_form,node_ticket_model,node_quantity_ajax,node_browser_script,node_db toneAmber
class node_ticket_page,node_notification_hook toneMint
class node_entity_template toneRose
class node_glpi toneIndigo
```

## Components

### Voucher management

- [Entity voucher form](https://github.com/pluginsglpi/credit/blob/main/front/entity.form.php): `front/entity.form.php`
- [Entity settings](https://github.com/pluginsglpi/credit/blob/main/front/entityconfig.form.php): `front/entityconfig.form.php`
- [Entity vouchers](https://github.com/pluginsglpi/credit/blob/main/inc/entity.class.php): `inc/entity.class.php`
- [Voucher types](https://github.com/pluginsglpi/credit/blob/main/inc/type.class.php): `inc/type.class.php`
- [Ticket settings](https://github.com/pluginsglpi/credit/blob/main/inc/ticketconfig.class.php): `inc/ticketconfig.class.php`

### Ticket consumption

- [Ticket voucher form](https://github.com/pluginsglpi/credit/blob/main/front/ticket.form.php): `front/ticket.form.php`
- [Consumption logic](https://github.com/pluginsglpi/credit/blob/main/inc/ticket.class.php): `inc/ticket.class.php`
- [Available quantity lookup](https://github.com/pluginsglpi/credit/blob/main/ajax/dropdownQuantity.php): `ajax/dropdownQuantity.php`
- [Form field updates](https://github.com/pluginsglpi/credit/blob/main/public/js/credit.js): `public/js/credit.js`

### Usage visibility

- [Consumption details](https://github.com/pluginsglpi/credit/blob/main/front/ticket.php): `front/ticket.php`
- [Ticket notification data](https://github.com/pluginsglpi/credit/blob/main/hook.php): `hook.php`

### Alerts and notifications

- [Entity alert templates](https://github.com/pluginsglpi/credit/blob/main/inc/notificationtargetentity.class.php): `inc/notificationtargetentity.class.php`

### Other components

- **GLPI user**
- **GLPI runtime**
- **GLPI database**

## Connections

- GLPI user → GLPI runtime: uses
- GLPI runtime → Entity voucher form: handles entity edits
- Entity voucher form → Entity vouchers: creates or updates
- Entity vouchers → GLPI database: stores vouchers
- GLPI runtime → Entity settings: handles settings
- Entity settings → Ticket settings: updates settings
- Ticket settings → GLPI database: stores settings
- GLPI runtime → Voucher types: manages dropdown types
- Voucher types → GLPI database: stores types
- GLPI runtime → Ticket voucher form: handles consumption entry
- Ticket voucher form → Consumption logic: adds consumption
- Consumption logic → GLPI database: reads and records use
- GLPI runtime → Consumption logic: dispatches ticket hooks
- Consumption logic → Entity vouchers: checks voucher balance
- GLPI runtime → Available quantity lookup: requests quantity
- Available quantity lookup → Entity vouchers: gets available maximum
- GLPI runtime → Form field updates: loads form behavior
- Form field updates → GLPI runtime: updates ticket selections
- GLPI runtime → Consumption details: opens consumption view
- Consumption details → Consumption logic: loads consumed details
- GLPI runtime → Ticket notification data: builds ticket notification data
- Ticket notification data → GLPI database: reads voucher totals
- GLPI runtime → Entity vouchers: runs credit checks
- Entity vouchers → Entity alert templates: raises expiry or low-credit event
- Entity alert templates → GLPI runtime: provides notification content
