Licence Seats Developer Guide - edmozley/freeitsm GitHub Wiki
๐ซ Licence seats and software by hand - Developer Guide
GitHub #437, raised by @bbieganski ยท Software, Assets, People, portal ยท built after 5.12.1 (#3242-#3246)
Who uses each licence, and software recorded on a device by hand. For how to use it, start at Software โ Seats.
Decided
| When | Question | Decision |
|---|---|---|
| 29 Nov 2026 | Licence seats, software by hand, or both? | Both (Ed). @bbieganski confirmed that some of his devices can't run the agent or Intune, so software by hand earns its place next to seats |
| 29 Nov 2026 | Over the quantity - refuse or allow? | Allow and flag. By the time anyone records a seat, the software is usually already in use and a true-up is on order. A refusal would only make the record wrong. The list shows it in red |
| 29 Nov 2026 | Who can a licence's seats go to? | By how it is counted: Per User goes to people, Per Device to devices, and Site, Concurrent, Other or unset to either |
| 29 Nov 2026 | The portal? | Behind a setting, off by default. Requesters were never shown licences before. Names only - never a key or a cost |
Seats
software_licence_assignments: one row per seat, with exactly one of user_id (a person) or asset_id (a device). A row with removed_datetime NULL counts as used. A removed row is kept, and the licence shows it under Earlier holders.
// includes/services/software_seats.php
SoftwareSeats::assign($conn, $analystId, $licenceId, 'person', $userId); // -> [seat_id, used, quantity, over]
SoftwareSeats::remove($conn, $analystId, $seatId); // kept as history
SoftwareSeats::used($conn, $licenceIds); // licence id => seats in use
SoftwareSeats::forPerson($conn, $userId); // their seats AND those of a device they hold (users_assets)
SoftwareSeats::forAsset($conn, $assetId);
- TRAP: over the quantity is never refused.
assign()returnsover: true, and the licence list and the licence window show it in red. - Licences belong to no company, but people and assets do. A seat can only go to someone or something the analyst can see (
analystCanAccessUser/analystCanAccessAsset), and the search usesactiveTenantReadFilter. A seat held in another company is counted, but shown as In a company you cannot see, with no name and no Remove. - The same holder twice is refused (
conflict). - Deleting a licence deletes its seats (
fk_sla_licence ... ON DELETE CASCADE, infreeitsm.sqland Database Verification). - Both
*_by_analyst_idcolumns are in the analyst lifecycle registry as history.
api/software/licence_seats.php:
GET ?licence_id=N -> { licence: {used, quantity, over, takes}, seats, history }
GET ?search=person|asset&q=... -> { results: [{id, name, detail}] }
POST { action: assign, licence_id, kind, holder_id, note }
POST { action: remove, seat_id }
get_licences.php returns seats_used per licence for the Used column, or null before Database Verification.
Software on a device by hand
The inventory agent and Intune record what is installed and keep it right. For a machine neither can reach, the device's Software tab can Add software by hand:
- It is a normal inventory row. Each one is a
software_inventory_detailrow withsource = 'manual', so every screen, report and API that reads inventory already shows it. - No source touches another source's rows.
AssetInventoryServiceandintune.phponly reconcile their own rows, so the agent never deletes a manual one. The test checks this the other way round too: an agent row can't be removed by hand. - One application once. The same application can only be added by hand once per device.
api/assets/manual_software.php
GET ?q=... applications to choose from
POST { action: add, asset_id, app_id, version }
POST { action: remove, asset_id, app_id } only a manual row
get_asset_software.php also returns licences (the device's seats, with translated type names, when the analyst can use Software) and can_add.
Where it shows
| Where | What |
|---|---|
| Software โ Licences | Used column; a licence's Seats - search, Add, Remove, earlier holders. ?licence=N opens one |
| People โ a person | Licences they use - their own seats, and those on a device they hold |
| Assets โ a device โ Software | Added by hand rows with Remove; Licences on this asset |
| Portal โ My equipment | With self_service_show_my_licences: licences on each device, software added by hand, and Your licences |
๐ Files
| File | Change |
|---|---|
๐ข includes/services/software_seats.php |
SoftwareSeats |
๐ข api/software/licence_seats.php, api/assets/manual_software.php |
The endpoints |
๐ก api/software/get_licences.php, api/assets/get_asset_software.php |
Seats used; a device's licences |
๐ก software/licences/index.php |
Used column, Seats panel |
๐ก asset-management/index.php |
Add by hand, Remove, licences |
๐ก includes/people.php, people/includes/render.php |
The person's Licences card |
๐ก api/self-service/get_my_assets.php, self-service/my-equipment.php, includes/self_service_settings.php, system/self-service/index.php |
The portal and its setting |
๐ฃ database/freeitsm.sql, includes/db_verify_schema.php, api/system/db_verify.php, includes/db_verify_indexes.php (generated) |
software_licence_assignments, its FK and indexes |
๐ข tests/licence-seats.php |
29 checks |
How it was proved
tests/licence-seats.php runs through the real endpoints on a test install and checks:
- Which kind of holder each licence takes, including the refusals.
- Duplicates are refused.
- Over the quantity is allowed, and reported as over.
- The licence list's count agrees.
- Removal is kept as history.
- A person's licences include those on a device they hold.
- Software by hand, with the agent's row as the control.
- The portal, with the setting off (the control) and on, and never a licence key.
- The lifecycle entries and the cascade on delete.
The licence list, the Seats panel, a person's card and a device's Software tab were also checked in a browser.