Lisää puhelinnumero yrityksen asetuksiin ja allekirjoituksiin
Puhelinnumero-kenttä yrityksen asetuksissa tallennetaan tietokantaan ja näkyy automaattisesti kaikissa oletusallekirjoituksissa viimeisenä rivinä (sekä SMTP- että Zammad-postilaatikoille). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
6
api.php
6
api.php
@@ -1499,7 +1499,7 @@ switch ($action) {
|
|||||||
foreach ($allCompanies as $comp) {
|
foreach ($allCompanies as $comp) {
|
||||||
// Superadmin näkee kaikki yritykset
|
// Superadmin näkee kaikki yritykset
|
||||||
if ($u['role'] === 'superadmin' || in_array($comp['id'], $userCompanies)) {
|
if ($u['role'] === 'superadmin' || in_array($comp['id'], $userCompanies)) {
|
||||||
$entry = ['id' => $comp['id'], 'nimi' => $comp['nimi']];
|
$entry = ['id' => $comp['id'], 'nimi' => $comp['nimi'], 'phone' => $comp['phone'] ?? ''];
|
||||||
// Merkitse IP-estetyt yritykset (superadmin ohittaa)
|
// Merkitse IP-estetyt yritykset (superadmin ohittaa)
|
||||||
if ($u['role'] !== 'superadmin' && !isIpAllowed($ip, $comp['allowed_ips'] ?? '')) {
|
if ($u['role'] !== 'superadmin' && !isIpAllowed($ip, $comp['allowed_ips'] ?? '')) {
|
||||||
$entry['ip_blocked'] = true;
|
$entry['ip_blocked'] = true;
|
||||||
@@ -1559,7 +1559,7 @@ switch ($action) {
|
|||||||
foreach ($allCompanies as $comp) {
|
foreach ($allCompanies as $comp) {
|
||||||
// Superadmin näkee kaikki yritykset
|
// Superadmin näkee kaikki yritykset
|
||||||
if ($isSuperAdmin || in_array($comp['id'], $userCompanyIds)) {
|
if ($isSuperAdmin || in_array($comp['id'], $userCompanyIds)) {
|
||||||
$entry = ['id' => $comp['id'], 'nimi' => $comp['nimi']];
|
$entry = ['id' => $comp['id'], 'nimi' => $comp['nimi'], 'phone' => $comp['phone'] ?? ''];
|
||||||
if (!$isSuperAdmin && !isIpAllowed($ip, $comp['allowed_ips'] ?? '')) {
|
if (!$isSuperAdmin && !isIpAllowed($ip, $comp['allowed_ips'] ?? '')) {
|
||||||
$entry['ip_blocked'] = true;
|
$entry['ip_blocked'] = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -3922,6 +3922,7 @@ switch ($action) {
|
|||||||
'smtp_from_email' => $mb['smtp_from_email'] ?? $mb['imap_user'] ?? '',
|
'smtp_from_email' => $mb['smtp_from_email'] ?? $mb['imap_user'] ?? '',
|
||||||
'company_id' => $comp['id'],
|
'company_id' => $comp['id'],
|
||||||
'company_nimi' => $comp['nimi'],
|
'company_nimi' => $comp['nimi'],
|
||||||
|
'company_phone' => $comp['phone'] ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4029,6 +4030,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
if (isset($input['primary_color'])) $c['primary_color'] = trim($input['primary_color']);
|
if (isset($input['primary_color'])) $c['primary_color'] = trim($input['primary_color']);
|
||||||
if (isset($input['subtitle'])) $c['subtitle'] = trim($input['subtitle']);
|
if (isset($input['subtitle'])) $c['subtitle'] = trim($input['subtitle']);
|
||||||
|
if (isset($input['phone'])) $c['phone'] = trim($input['phone']);
|
||||||
if (isset($input['enabled_modules']) && is_array($input['enabled_modules'])) {
|
if (isset($input['enabled_modules']) && is_array($input['enabled_modules'])) {
|
||||||
$c['enabled_modules'] = array_values($input['enabled_modules']);
|
$c['enabled_modules'] = array_values($input['enabled_modules']);
|
||||||
}
|
}
|
||||||
|
|||||||
7
db.php
7
db.php
@@ -768,11 +768,11 @@ function dbSaveCompany(array $company): void {
|
|||||||
$enabledModules = $company['enabled_modules'] ?? [];
|
$enabledModules = $company['enabled_modules'] ?? [];
|
||||||
$enabledModulesJson = is_array($enabledModules) ? json_encode($enabledModules) : ($enabledModules ?: '');
|
$enabledModulesJson = is_array($enabledModules) ? json_encode($enabledModules) : ($enabledModules ?: '');
|
||||||
_dbExecute("
|
_dbExecute("
|
||||||
INSERT INTO companies (id, nimi, luotu, aktiivinen, primary_color, subtitle, logo_file, api_key, cors_origins, enabled_modules, allowed_ips)
|
INSERT INTO companies (id, nimi, luotu, aktiivinen, primary_color, subtitle, phone, logo_file, api_key, cors_origins, enabled_modules, allowed_ips)
|
||||||
VALUES (:id, :nimi, :luotu, :aktiivinen, :primary_color, :subtitle, :logo_file, :api_key, :cors_origins, :enabled_modules, :allowed_ips)
|
VALUES (:id, :nimi, :luotu, :aktiivinen, :primary_color, :subtitle, :phone, :logo_file, :api_key, :cors_origins, :enabled_modules, :allowed_ips)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
nimi = VALUES(nimi), aktiivinen = VALUES(aktiivinen),
|
nimi = VALUES(nimi), aktiivinen = VALUES(aktiivinen),
|
||||||
primary_color = VALUES(primary_color), subtitle = VALUES(subtitle),
|
primary_color = VALUES(primary_color), subtitle = VALUES(subtitle), phone = VALUES(phone),
|
||||||
logo_file = VALUES(logo_file), api_key = VALUES(api_key), cors_origins = VALUES(cors_origins),
|
logo_file = VALUES(logo_file), api_key = VALUES(api_key), cors_origins = VALUES(cors_origins),
|
||||||
enabled_modules = VALUES(enabled_modules), allowed_ips = VALUES(allowed_ips)
|
enabled_modules = VALUES(enabled_modules), allowed_ips = VALUES(allowed_ips)
|
||||||
", [
|
", [
|
||||||
@@ -782,6 +782,7 @@ function dbSaveCompany(array $company): void {
|
|||||||
'aktiivinen' => $company['aktiivinen'] ?? true,
|
'aktiivinen' => $company['aktiivinen'] ?? true,
|
||||||
'primary_color' => $company['primary_color'] ?? '#0f3460',
|
'primary_color' => $company['primary_color'] ?? '#0f3460',
|
||||||
'subtitle' => $company['subtitle'] ?? '',
|
'subtitle' => $company['subtitle'] ?? '',
|
||||||
|
'phone' => $company['phone'] ?? '',
|
||||||
'logo_file' => $company['logo_file'] ?? '',
|
'logo_file' => $company['logo_file'] ?? '',
|
||||||
'api_key' => $company['api_key'] ?? '',
|
'api_key' => $company['api_key'] ?? '',
|
||||||
'cors_origins' => $company['cors_origins'] ?? '',
|
'cors_origins' => $company['cors_origins'] ?? '',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Noxus HUB</title>
|
<title>Noxus HUB</title>
|
||||||
<link rel="stylesheet" href="style.css?v=20260313e">
|
<link rel="stylesheet" href="style.css?v=20260313f">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Login -->
|
<!-- Login -->
|
||||||
@@ -1615,6 +1615,10 @@
|
|||||||
<label>Alaotsikko</label>
|
<label>Alaotsikko</label>
|
||||||
<input type="text" id="company-edit-subtitle" placeholder="esim. Asiakashallinta">
|
<input type="text" id="company-edit-subtitle" placeholder="esim. Asiakashallinta">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Puhelinnumero</label>
|
||||||
|
<input type="text" id="company-edit-phone" placeholder="esim. 020 778 0730">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Pääväri</label>
|
<label>Pääväri</label>
|
||||||
<div style="display:flex;align-items:center;gap:0.5rem;">
|
<div style="display:flex;align-items:center;gap:0.5rem;">
|
||||||
@@ -2229,6 +2233,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js?v=20260313e"></script>
|
<script src="script.js?v=20260313f"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
19
script.js
19
script.js
@@ -2392,15 +2392,17 @@ async function initTicketSettings() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Oletusallekirjoitus: Käyttäjänimi + Yritys + sähköposti
|
// Oletusallekirjoitus: Käyttäjänimi + Yritys + sähköposti + puhelin (jos asetettu)
|
||||||
const userName = currentUser?.nimi || currentUser?.username || '';
|
const userName = currentUser?.nimi || currentUser?.username || '';
|
||||||
function defaultSig(companyName, email) {
|
function defaultSig(companyName, email, phone) {
|
||||||
return userName + '\n' + companyName + '\n' + email;
|
let sig = userName + '\n' + companyName + '\n' + email;
|
||||||
|
if (phone) sig += '\n' + phone;
|
||||||
|
return sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allekirjoitukset per postilaatikko
|
// Allekirjoitukset per postilaatikko
|
||||||
let sigHtml = mailboxes.map(mb => {
|
let sigHtml = mailboxes.map(mb => {
|
||||||
const sig = currentUserSignatures[mb.id] || defaultSig(mb.company_nimi, mb.smtp_from_email);
|
const sig = currentUserSignatures[mb.id] || defaultSig(mb.company_nimi, mb.smtp_from_email, mb.company_phone);
|
||||||
return `<div style="margin-bottom:0.75rem;">
|
return `<div style="margin-bottom:0.75rem;">
|
||||||
<label style="font-weight:600;font-size:0.85rem;color:#333;">${esc(mb.company_nimi)} — ${esc(mb.nimi)}</label>
|
<label style="font-weight:600;font-size:0.85rem;color:#333;">${esc(mb.company_nimi)} — ${esc(mb.nimi)}</label>
|
||||||
<textarea class="ticket-sig-textarea" data-mailbox-id="${mb.id}" rows="3"
|
<textarea class="ticket-sig-textarea" data-mailbox-id="${mb.id}" rows="3"
|
||||||
@@ -2415,9 +2417,10 @@ async function initTicketSettings() {
|
|||||||
if (zammadEmails.length > 0) {
|
if (zammadEmails.length > 0) {
|
||||||
sigHtml += '<div style="margin-top:0.75rem;padding-top:0.75rem;border-top:1px solid #eee;"><strong style="font-size:0.85rem;color:#666;">Zammad-sähköpostit</strong></div>';
|
sigHtml += '<div style="margin-top:0.75rem;padding-top:0.75rem;border-top:1px solid #eee;"><strong style="font-size:0.85rem;color:#666;">Zammad-sähköpostit</strong></div>';
|
||||||
const companyName = currentCompany?.nimi || '';
|
const companyName = currentCompany?.nimi || '';
|
||||||
|
const companyPhone = currentCompany?.phone || '';
|
||||||
zammadEmails.forEach(email => {
|
zammadEmails.forEach(email => {
|
||||||
const key = 'zammad:' + email;
|
const key = 'zammad:' + email;
|
||||||
const sig = currentUserSignatures[key] || defaultSig(companyName, email);
|
const sig = currentUserSignatures[key] || defaultSig(companyName, email, companyPhone);
|
||||||
sigHtml += `<div style="margin-bottom:0.75rem;">
|
sigHtml += `<div style="margin-bottom:0.75rem;">
|
||||||
<label style="font-weight:600;font-size:0.85rem;color:#333;">${esc(email)} <span style="color:#888;font-size:0.8rem;">(Zammad)</span></label>
|
<label style="font-weight:600;font-size:0.85rem;color:#333;">${esc(email)} <span style="color:#888;font-size:0.8rem;">(Zammad)</span></label>
|
||||||
<textarea class="ticket-sig-textarea" data-mailbox-id="${esc(key)}" rows="3"
|
<textarea class="ticket-sig-textarea" data-mailbox-id="${esc(key)}" rows="3"
|
||||||
@@ -2748,6 +2751,7 @@ async function showCompanyDetail(id) {
|
|||||||
document.getElementById('company-edit-nimi').value = comp ? comp.nimi : '';
|
document.getElementById('company-edit-nimi').value = comp ? comp.nimi : '';
|
||||||
// Brändäyskentät
|
// Brändäyskentät
|
||||||
document.getElementById('company-edit-subtitle').value = comp?.subtitle || '';
|
document.getElementById('company-edit-subtitle').value = comp?.subtitle || '';
|
||||||
|
document.getElementById('company-edit-phone').value = comp?.phone || '';
|
||||||
const color = comp?.primary_color || '#0f3460';
|
const color = comp?.primary_color || '#0f3460';
|
||||||
document.getElementById('company-edit-color').value = color;
|
document.getElementById('company-edit-color').value = color;
|
||||||
document.getElementById('company-edit-color-text').value = color;
|
document.getElementById('company-edit-color-text').value = color;
|
||||||
@@ -3027,6 +3031,7 @@ document.getElementById('btn-save-company-settings').addEventListener('click', a
|
|||||||
const nimi = document.getElementById('company-edit-nimi').value.trim();
|
const nimi = document.getElementById('company-edit-nimi').value.trim();
|
||||||
if (!nimi) return;
|
if (!nimi) return;
|
||||||
const subtitle = document.getElementById('company-edit-subtitle').value.trim();
|
const subtitle = document.getElementById('company-edit-subtitle').value.trim();
|
||||||
|
const phone = document.getElementById('company-edit-phone').value.trim();
|
||||||
const primary_color = document.getElementById('company-edit-color').value;
|
const primary_color = document.getElementById('company-edit-color').value;
|
||||||
const domainsText = document.getElementById('company-edit-domains').value;
|
const domainsText = document.getElementById('company-edit-domains').value;
|
||||||
const domains = domainsText.split('\n').map(d => d.trim()).filter(d => d);
|
const domains = domainsText.split('\n').map(d => d.trim()).filter(d => d);
|
||||||
@@ -3037,11 +3042,11 @@ document.getElementById('btn-save-company-settings').addEventListener('click', a
|
|||||||
});
|
});
|
||||||
const allowed_ips = document.getElementById('company-edit-allowed-ips').value.trim();
|
const allowed_ips = document.getElementById('company-edit-allowed-ips').value.trim();
|
||||||
try {
|
try {
|
||||||
await apiCall('company_update', 'POST', { id: currentCompanyDetail, nimi, subtitle, primary_color, domains, enabled_modules, allowed_ips });
|
await apiCall('company_update', 'POST', { id: currentCompanyDetail, nimi, subtitle, phone, primary_color, domains, enabled_modules, allowed_ips });
|
||||||
alert('Asetukset tallennettu!');
|
alert('Asetukset tallennettu!');
|
||||||
// Päivitä paikalliset tiedot
|
// Päivitä paikalliset tiedot
|
||||||
const comp = companiesTabData.find(c => c.id === currentCompanyDetail);
|
const comp = companiesTabData.find(c => c.id === currentCompanyDetail);
|
||||||
if (comp) { comp.nimi = nimi; comp.subtitle = subtitle; comp.primary_color = primary_color; comp.domains = domains; comp.enabled_modules = enabled_modules; comp.allowed_ips = allowed_ips; }
|
if (comp) { comp.nimi = nimi; comp.subtitle = subtitle; comp.phone = phone; comp.primary_color = primary_color; comp.domains = domains; comp.enabled_modules = enabled_modules; comp.allowed_ips = allowed_ips; }
|
||||||
const avail = availableCompanies.find(c => c.id === currentCompanyDetail);
|
const avail = availableCompanies.find(c => c.id === currentCompanyDetail);
|
||||||
if (avail) avail.nimi = nimi;
|
if (avail) avail.nimi = nimi;
|
||||||
populateCompanySelector();
|
populateCompanySelector();
|
||||||
|
|||||||
Reference in New Issue
Block a user