Contracts - edmozley/freeitsm GitHub Wiki

Contracts

Folder: contracts/ Colour: Amber #f59e0b

Supplier and contract lifecycle management with configurable rich-text terms, supplier register, contact directory, and an AI-powered RFP Builder for procurement-led tendering. A contract can be with a supplier you buy from or a customer you sell to β€” see Contracts with customers.

Dashboard (index.php)

Left sidebar with:

  • Overview stats: contracts, active, expiring (90 day), suppliers, contacts
  • Quick Links: Suppliers, Contacts, RFP Builder, Settings
  • Universal search modal across contracts, suppliers, and contacts

Every contract belongs to a company (3.5.0) β€” set in Company at the top of the form, and the list follows the company switcher; see Who can see a contract.

Main pane is a full-width contracts table with column sorting and a + New Contract CTA. The With column shows the supplier or the customer (customer contracts carry a Customer badge), and a drop-down above the table narrows it to suppliers or customers.

Add / Edit (edit.php)

Sectioned form covering:

  • Contract details (number, title, status, description, owner, and Contract with β€” a supplier, or a customer: a company, a person from Users, or both)
  • Dates (start, end, notice period, notice date)
  • Financial (value, currency, payment schedule, cost centre)
  • Documents (DMS link)
  • Terms & data protection (terms status, personal data transferred, DPIA required + completed date + DPIA DMS link)

Below the main form, a Contract Terms Detail section displays configurable TinyMCE rich-text tabs (e.g. Special terms, KPIs, SLAs) β€” the tab set is configured in Settings.

Save / Cancel pinned in a sticky footer at the bottom of the scrolling main pane so they're always within reach on long forms.

View (view.php)

Read-only detail view with all fields organised into sections. Contract-terms content displayed in read-only tabs. Header buttons:

  • Task β€” opens an inline modal that prefills sensible defaults (title, description, due date = notice date or end date, assignee = contract owner) and links the new task back via contract_id
  • Calendar β€” same pattern for a new calendar event

Below the contract details: an Equipment panel, plus Related Tasks and Related Calendar Events sections listing everything currently linked.

Equipment lists the assets this contract covers β€” phones and SIMs on a mobile agreement, a router on an internet agreement, machines on a maintenance contract. Add them with a search picker; each link carries an optional reference such as a phone number, and an asset gains a Contracts tab showing the supplier, the end date and the notice date. See Equipment covered by a contract.

⚠️ Since 3.5.0 a contract belongs to a company and covers only that company's equipment β€” the picker offers only its assets, and linking another company's is refused. The equipment list is still filtered to what the reader can reach, and reports no count of what was withheld.

Suppliers (suppliers/)

Supplier register with:

  • Legal / trading names
  • Registration number / VAT / tax ID
  • Address (line 1 / 2 / city / county / postcode / country)
  • Supplier type, supplier status (both configurable)
  • Questionnaire tracking (date issued, date received)
  • Comments
  • Active flag

Layout: left sidebar with Overview totals broken down by supplier type and status; full-width section-card table on the right. Eye icon per row links to a dedicated supplier view page at suppliers/view/?id=X showing every field in the same grouping as the edit modal but rendered inline β€” with the edit modal embedded so the pencil icon opens it in place.

Contacts (contacts/)

Supplier contacts with:

  • Name (first / surname)
  • Job title
  • Email (clickable mailto: link)
  • Mobile, direct dial, switchboard
  • Linked supplier (clickable through to the supplier view)
  • Active flag

Same sidebar pattern as Suppliers β€” Overview groups contacts by supplier with Active / Inactive counts per supplier.

Settings (settings/)

Tabbed management of:

  • Supplier types (e.g. Software vendor, Hardware reseller, Telecoms)
  • Supplier statuses (e.g. Active, Pending review, Cease use)
  • Contract statuses
  • Payment schedules (e.g. Monthly, Quarterly, Annual upfront)
  • Contract term tabs β€” the tab set that appears in the contract editor's Terms Detail section

RFP Builder (rfp-builder/)

AI-powered procurement requirements builder for end-to-end RFP generation.

Every RFP belongs to a company (3.5.0) β€” Company on the New / Edit RFP form, the company you are working in by default. Only analysts who can see that company see the RFP, its documents, requirements, sections and scores; the list follows the company switcher, and an RFP's contract must be in its company. Suppliers and RFP departments stay shared by every company.

πŸ”§ Developers: includes/rfp_scope.php. Every endpoint in api/rfp-builder/ calls rfpGate(kind, key) right after its module check β€” it reads the id from the query, form or JSON body, finds its RFP (rfpIdOf: documents, extracted and consolidated requirements, conflicts, sections, framing, invited suppliers) and answers RFP not found for one out of reach. The five streaming endpoints use rfpCanView() and answer as an event. get_rfps.php uses rfpListSql(). tests/rfp-companies.php fails if an endpoint is added without the gate.

  • Phase 1: Upload departmental feedback documents (one per department) β€” DOCX, PDF, plain text
  • Phase 2: AI extracts every requirement / pain point / challenge from each document
  • Phase 3: A single AI consolidation pass deduplicates across departments, proposes 8–20 RFP categories, assigns priorities, and flags genuine contradictions
  • Phase 4 β€” Generation: Introduction + scope + response instructions framing plus per-category sections, all streamed live (claude.ai-style SSE) with live progress trackers, TinyMCE editing per section, version history with restore, Pass 4 restyle that re-applies the style guide without changing meaning, and a print-friendly preview page for PDF export
  • Phase 5 β€” Supplier scoring: Click-to-light 0–5 score boxes (redβ†’green gradient), per-category running averages, full-screen radar chart, multi-analyst rollup
  • Cross-supplier compare: Big-number cards, multi-supplier radar overlay, category winners table marking the leader and gap

Manual editing tools β€” edit / split / merge / add custom / conflict resolve β€” refine the consolidated set. Lock to gate Phase 4 generation so consolidation is finalised before the AI starts drafting.

Additional surfaces:

  • Coverage heatmap β€” category Γ— department visualisation
  • AI activity panel + full filterable audit trail
  • In-app help guide with the same scroll-spy pattern as other help pages

Help (help.php)

Guided help page with left-pane navigation, scroll-spy, and 7 sections covering contract management, rich-text terms, suppliers, contacts, settings configuration, and best practice tips.

Key Tables

Table Purpose
contracts Core contract record
contract_terms Per-term-tab rich-text content per contract
contract_term_tabs Configurable tab definitions
contract_statuses Status lookup
payment_schedules Schedule lookup
suppliers Supplier register
supplier_types, supplier_statuses Lookups
contacts Supplier contacts
rfp_* RFP Builder tables (uploads, requirements, categories, drafts, versions, scoring)