'vendor templates', 'title' => 'That vendor template is gone', 'text' => 'It may have been deleted.', 'icon' => 'fa-building', 'filtered' => false, 'actions' => [['label' => 'Vendor Templates', 'href' => 'vendor_templates.php']]]); require_once "../includes/footer.php"; exit(); } $vendor_template_id = intval($template['vendor_template_id']); $name = escapeHtml($template['vendor_template_name']); // Tab title - used raw, the footer encodes it $page_title = $template['vendor_template_name']; $archived = !empty($template['vendor_template_archived_at']); $usage = vendorTemplateUsage([$vendor_template_id])[$vendor_template_id] ?? ['clients' => 0, 'vendors' => 0, 'ours' => 0, 'last' => null]; $csrf = $_SESSION['csrf_token']; // Its vendors - the current ones for current clients listed, the rest counted $all_vendors = vendorTemplateVendors($vendor_template_id); $current = array_filter($all_vendors, function ($vendor) { return !$vendor['archived'] && !$vendor['client_archived']; }); $set_up = count(array_filter($current, function ($vendor) { return $vendor['client_id'] && $vendor['account_number'] !== ''; })); $client_vendors = count(array_filter($current, function ($vendor) { return $vendor['client_id'] > 0; })); $out_of_step = count(array_filter($current, function ($vendor) { return (bool) $vendor['differences']; })); $others = count($all_vendors) - count($current); $license_templates = vendorTemplateLicenseTemplates($vendor_template_id); // ...seen all at once, the ones out of step, or the ones without the client's account number $views = [ '' => ['label' => 'All', 'icon' => 'fa-list', 'title' => 'Every current vendor made from it', 'test' => function ($vendor) { return true; }], 'out' => ['label' => 'Out of step', 'icon' => 'fa-not-equal', 'title' => 'Saying something other than the template does', 'test' => function ($vendor) { return (bool) $vendor['differences']; }], 'account' => ['label' => 'No account number', 'icon' => 'fa-fingerprint', 'title' => "Without the client's account number", 'test' => function ($vendor) { return $vendor['client_id'] && $vendor['account_number'] === ''; }], ]; $view = is_string($_GET['view'] ?? null) && isset($views[$_GET['view']]) ? $_GET['view'] : ''; $view_counts = []; foreach ($views as $key => $definition) { $view_counts[$key] = count(array_filter($current, $definition['test'])); } $vendors = array_filter($current, $views[$view]['test']); $view_url = function ($key) use ($vendor_template_id) { return '?' . http_build_query(array_filter(['vendor_template_id' => $vendor_template_id, 'view' => $key])) . '#vendorTemplateVendors'; }; // Vendors made by hand that look like it - not offered while it is archived $matches = $archived ? [] : vendorTemplateMatches($vendor_template_id); // Who should have one - not counted while it is archived $required = intval($template['vendor_template_required']); $required_tags = vendorTemplateRequiredTags([$vendor_template_id])[$vendor_template_id]; $scope_text = vendorTemplateScopeText($required, $required_tags); $coverage = $required && !$archived ? vendorTemplateCoverage($vendor_template_id, $required, array_keys($required_tags)) : null; $list_limit = 8; $missing_text = $coverage && $coverage['missing'] ? (count($coverage['missing']) === 1 ? 'the client missing it' : 'the ' . count($coverage['missing']) . ' clients missing it') : ''; $edit_url = "modals/vendor_template/vendor_template_edit.php?id=$vendor_template_id"; $clients_url = "/agent/modals/vendor/vendor_template_clients.php?template_id=$vendor_template_id"; $required_url = "modals/vendor_template/vendor_template_required.php?id=$vendor_template_id"; $update_url = "/agent/modals/vendor/vendor_template_update.php"; $in_line_url = "$update_url?template_id=$vendor_template_id"; // What a vendor from it starts with - the ones it has $t = $template; $link = function ($site) { $url = vendorWebsiteUrl($site); return $url !== '' ? '' . escapeHtml(vendorWebsiteLabel($site)) . '' : ''; }; // The account manager every client shares - their name, with their line and email under it $manager = array_filter([ escapeHtml(trim((string) $t['vendor_template_contact_name'])), trim((string) $t['vendor_template_contact_phone']) !== '' ? '' . contactPhoneLink($t['vendor_template_contact_phone'], $t['vendor_template_contact_phone_country_code']) : '', trim((string) $t['vendor_template_contact_email']) !== '' ? '' . escapeHtml($t['vendor_template_contact_email']) . '' : '', ]); $facts = array_filter([ 'What they are' => escapeHtml((string) $t['vendor_template_description']), 'Support line' => vendorTemplatePhoneHtml($t['vendor_template_phone'], $t['vendor_template_phone_country_code'], $t['vendor_template_extension']), 'Support hours' => escapeHtml((string) $t['vendor_template_hours']), 'SLA' => escapeHtml((string) $t['vendor_template_sla']), 'Support email' => trim((string) $t['vendor_template_email']) !== '' ? '' . escapeHtml($t['vendor_template_email']) . '' : '', 'Support site' => $link($t['vendor_template_website']), 'Status page' => $link($t['vendor_template_status_page']), 'Support portal' => $link($t['vendor_template_portal']), 'Account number' => escapeHtml(trim((string) $t['vendor_template_account_number'])), 'PIN' => vendorSecretHtml($t['vendor_template_code']), 'Account manager' => $manager ? '
| Client | Their vendor | In step | Account | Added | ||
|---|---|---|---|---|---|---|
|
= escapeHtml($vendor['client_name']) ?>
Ours
= escapeHtml($vendor['vendor_name']) ?>
|
= escapeHtml($vendor['vendor_name']) ?> | = escapeHtml($differs_text) ?> In step | = escapeHtml($vendor['account_number']) ?> No account number - | = date('M j, Y', strtotime($vendor['created_at'])) ?> |
|