mirror of
https://github.com/itflow-org/itflow
synced 2026-11-21 03:47:25 +00:00
Document templates stage 2, filled in from the client: placeholders [Client], [Website], [Site], [Address], [Site Phone], [Contact], [First Name], [Contact Email], [Contact Phone], [Agent], [Date], [Month], [Quarter] and [Year] are filled in across a template's name, summary and content when a document is made, using the client's primary site and contact unless another or none is picked; tables of records [Contacts], [Locations], [Assets], [Servers], [Workstations], [Network Equipment], [Printers], [Networks], [Domains], [Certificates], [Licenses], [Vendors] and [Services] put in the client's current records, as a table on a line of their own (an empty row when there are none) or as names in a sentence, all made safe; any other bracketed word is a fill-in asked for when a document is made, set up on the template page as text, date, list or yes/no, required or with help, renamed along with the template text, reset or removed, and dragged into order, with answers checked by ticketFillInAnswers and blanks left in the document; the template page gets Fill-ins and Filled in from the client cards with each kind of word marked in its own colour, and the editor gets a button for each placeholder and table to insert it at the cursor (js/document_template_form.js); New document for a client and Document from template draw the site and contact pickers and fill-ins once the template and client are picked (agent/ajax.php document_template_asks, agent/js/document_template_make.js) and open larger; copying a template copies its fill-ins; Draft it with AI is told the placeholders and tables; migration 3.2.6 adds document_template_fill_ins; fixed the fill-in add and reset messages showing raw HTML around the bracketed name on document and ticket templates; changelog updated
This commit is contained in:
@@ -132,13 +132,22 @@ if (isset($_POST['add_document_from_template'])) {
|
||||
|
||||
$folder = folderOwnedId($_POST['folder'] ?? 0, $client_id);
|
||||
|
||||
// A copy of what it says and its images, remembering the template (functions/document_template.php)
|
||||
$template = documentTemplateRow($document_template_id);
|
||||
$document_id = documentTemplateMakeDocument($document_template_id, $client_id, $_POST['name'] ?? '', $_POST['description'] ?? '', $folder);
|
||||
if (!$document_id) {
|
||||
if (!$template || $template['document_template_archived_at']) {
|
||||
flashAlert('That template is gone or archived.', 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
// What it asks for, answered - a required one left blank, or an answer that isn't one, says so
|
||||
$answers = ticketFillInAnswers(documentTemplateFillInsFor($document_template_id), $_POST['fill_ins'] ?? [], $fill_in_error);
|
||||
if ($answers === null) {
|
||||
flashAlert($fill_in_error, 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
// A copy of what it says and its images, filled in for the client and remembering the template (functions/document_template.php)
|
||||
$document_id = documentTemplateMakeDocument($document_template_id, $client_id, $_POST['name'] ?? '', $_POST['description'] ?? '', $folder,
|
||||
intval($_POST['location_id'] ?? 0), intval($_POST['contact_id'] ?? 0), $answers);
|
||||
$document_name = (string) getFieldById('documents', $document_id, 'document_name');
|
||||
|
||||
logAudit("Document", "Create", "$session_name created document " . escapeSql($document_name) . " from template " . escapeSql($template['document_template_name']), $client_id, $document_id);
|
||||
|
||||
Reference in New Issue
Block a user