';
}
return $html;
}
/** Label and value pairs, leaving out the empty ones - [label => value HTML]. '' when none are left. */
function printSheetFieldsHtml(array $fields) {
$html = '';
foreach ($fields as $label => $value) {
if (trim(strip_tags((string) $value)) === '') {
continue;
}
$html .= '
' . escapeHtml($label) . '
' . $value . '
';
}
return $html === '' ? '' : '
' . $html . '
';
}
/** A boxed block with a small heading - '' when it has nothing in it. */
function printSheetBoxHtml($heading, $body_html) {
if (trim(strip_tags((string) $body_html, '')) === '') {
return '';
}
return '
' . escapeHtml($heading) . '
' . $body_html . '
';
}
/** A section of the sheet - a heading over its body; '' when it has nothing in it. */
function printSheetSectionHtml($heading, $body_html, $attributes = '') {
if (trim(strip_tags((string) $body_html, '')) === '') {
return '';
}
return '
' . escapeHtml($heading) . '
' . $body_html . '';
}
/** Ruled lines to write on. */
function printSheetLinesHtml($count) {
return '
' . str_repeat('', max(1, intval($count))) . '
';
}
/** Who printed it and when, for the foot of a sheet. */
function printSheetPrintedText() {
global $session_name;
return 'Printed ' . formatDateTime(date('Y-m-d H:i:s')) . (!empty($session_name) ? ' by ' . $session_name : '');
}
/** Lines of text with line breaks kept, escaped. */
function printSheetText($text) {
return nl2br(escapeHtml(trim((string) $text)));
}
/*
* A ticket's work order: who and where, the job's details, its assets, the description, the
* fill-ins the client can see, the tasks to tick, its public replies oldest first, and lines to
* sign off on-site work. $ticket is agent/ticket.php's row (the ticket with its client, contact,
* location, asset, assignee, status and category); $replies its replies, any order.
*/
function ticketWorkOrderHtml(array $ticket, $purifier, array $replies) {
global $mysqli;
$ticket_id = intval($ticket['ticket_id']);
$client_id = intval($ticket['ticket_client_id']);
// Who it's for
$contact_lines = [];
if (!empty($ticket['contact_name'])) {
$contact_lines[] = '
';
}
}
if (!empty($ticket['contact_email'])) {
$contact_lines[] = '
' . escapeHtml($ticket['contact_email']) . '
';
}
}
$for_html = ($client_id ? '
' . escapeHtml($ticket['client_name']) . '
' : '') . implode('', $contact_lines);
// Where - the site, how to get in
$site_html = '';
if (intval($ticket['location_id'] ?? 0)) {
$address = locationAddressText($ticket, true);
$site_html = '
';
return $html;
}
/*
* An asset's spec sheet: what it is, its hardware and network, where it is and who has it, its
* interfaces, what is in it, the licenses and services it is part of, and its quick notes - with
* a QR code that opens it in ITFlow. $row is agent/asset.php's row; $more what the page worked
* out for its tabs (interfaces and their links, licenses, services, rack, guests, holds, specs).
*/
function assetSpecSheetHtml(array $row, array $more) {
global $config_base_url;
$asset_id = intval($row['asset_id']);
$client_id = intval($row['client_id']);
// Hardware
$hardware = [
'Type' => escapeHtml($row['asset_type']),
'Model' => escapeHtml(trim($row['asset_make'] . ' ' . $row['asset_model'])),
'Serial' => '' . escapeHtml($row['asset_serial']) . '',
(assetTypeOsLabel($row['asset_type']) === 'Firmware' ? 'Firmware' : 'OS') => escapeHtml($row['asset_os']),
];
// Its type's details - dates as dates, as "in 23 days" goes stale on paper
foreach ($more['spec_rows'] ?? [] as $spec_row) {
$hardware[$spec_row['label']] = escapeHtml($spec_row['flag']
? formatDate($spec_row['flag']['date']) . ($spec_row['flag']['tone'] === 'danger' ? ' - overdue' : '')
: $spec_row['text']);
}
if (!empty($more['guests'])) {
$hardware['Runs'] = escapeHtml(implode(', ', $more['guests']));
}
$warranty = assetWarranty($row['asset_warranty_expire'] ?? '');
$hardware['Warranty'] = $warranty ? escapeHtml(($warranty['tone'] === 'danger' ? 'Ended ' : 'Until ') . formatDate($warranty['date'])) : '';
$hardware['Purchased'] = escapeHtml(formatDate($row['asset_purchase_date']));
$hardware['Installed'] = escapeHtml(formatDate($row['asset_install_date']));
$hardware['Vendor'] = escapeHtml($row['vendor_name']);
$hardware['Order ref'] = escapeHtml($row['asset_purchase_reference']);
// Network - its primary address, and its links
$network = [
'IP' => '' . escapeHtml($row['interface_ip']) . '',
'NAT' => '' . escapeHtml($row['interface_nat_ip']) . '',
'IPv6' => '' . escapeHtml($row['interface_ipv6']) . '',
'MAC' => '' . escapeHtml($row['interface_mac']) . '',
'Network' => escapeHtml($row['network_name']),
];
foreach (assetLinks($row['asset_uri'], $row['asset_uri_2'], $row['asset_uri_client']) as [$label, $url]) {
$network[$label === 'Client link' ? 'Client link' : 'Link'] = ($network[$label === 'Client link' ? 'Client link' : 'Link'] ?? '') . '
' . escapeHtml($url) . '
';
}
// Where it is, and who has it
$rack = $more['rack'] ?? null;
$where = [
'Client' => escapeHtml($row['client_name']),
'Location' => escapeHtml($row['location_name']) . (trim((string) $row['asset_physical_location']) !== '' ? '
' : '';
// What is in it - a chassis and its nodes
$holds_rows = '';
foreach ($more['holds'] ?? [] as $held) {
// rackUnitView() items come escaped
$holds_rows .= '