Commit Graph

248 Commits

Author SHA1 Message Date
5ea01ce7b3 Lisää oletusallekirjoitus kaikille käyttäjille
Jos käyttäjä ei ole asettanut omaa allekirjoitusta mailboxille,
generoidaan automaattisesti oletus:
  Etunimi
  Yrityksen nimi
  Postilaatikon sähköpostiosoite

Toimii sekä esikatselu-previewssä että sähköpostin lähetyksessä.
Käyttäjä voi yliajaa oletuksen tallentamalla oman allekirjoituksen
profiilin kautta.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:21:35 +02:00
2da63262a7 Näytä SMTP-portti ja salaus aina mailbox-lomakkeessa
Portti ja salaus tarvitaan aina (IMAP=993/SSL vs SMTP=587/TLS),
joten ne näkyvät nyt checkboxin tilasta riippumatta.
"Käytä samoja tunnuksia" piilottaa vain palvelimen, käyttäjän
ja salasanan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:14:20 +02:00
eaf47d5b78 Yhdistä IMAP/SMTP-asetukset vierekkäin + "Käytä samoja tunnuksia"
Mailbox-lomake näyttää nyt Saapuva (IMAP) ja Lähtevä (SMTP)
vierekkäin. SMTP-puolella on "Käytä samoja tunnuksia kuin
saapuvassa" -checkbox (oletuksena päällä), joka piilottaa
SMTP-kentät ja kopioi IMAP-asetukset tallennettaessa.
Lähettäjän sähköposti ja nimi omana osionaan alhaalla.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:50:45 +02:00
78f25d0079 Lisää SMTP-lähetystuki postilaatikoihin
Aiemmin sähköpostit lähetettiin PHP mail()-funktiolla, mikä
ei toimi kunnolla useimmilla palvelimilla (SPF/DKIM-ongelmat).
Nyt mailboxiin voi konfiguroida SMTP-asetukset (host, port,
user, pass, encryption), ja lähetys tapahtuu suoraan
SMTP-palvelimen kautta socket-yhteydellä. Fallback PHP
mail():iin jos SMTP-asetuksia ei ole asetettu.

- db.php: smtp_host/port/user/password/encryption sarakkeet
- api.php: sendViaSMTP() socket-pohjainen SMTP-client
- index.html: SMTP-kentät mailbox-lomakkeeseen
- script.js: SMTP-kenttien luku/kirjoitus lomakkeessa

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:46:28 +02:00
a13f3e00a5 Paranna allekirjoituksen esikatselu-logiikkaa
Lisää fallback-haku: kokeillaan ensin suoraan mailbox-id:llä,
sitten string/number-konversiolla, ja lopuksi käytetään
ensimmäistä löytyvää allekirjoitusta jos mitään ei matchaa.
Tämä korjaa tilanteen jossa mailbox_id:n tyyppi ei täsmää
tai tiketti on tullut tuntemattoman mailboxin kautta.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:30:36 +02:00
e1cc95f306 Siirrä allekirjoituksen esikatselu checkboxin alle
Käyttäjä näkee nyt "Käytä allekirjoitusta" -täpän alla
suoraan mitä allekirjoitustekstiä viestiin liitetään.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:18:03 +02:00
5d6aa981b2 feat: TO-kenttä näkyviin vastauslomakkeessa
- Vastaanottaja (TO) näkyy nyt Lähettäjä- ja CC-kenttien välissä
- Esitäytetään tiketin alkuperäisen lähettäjän osoitteella
- Muokattavissa ennen lähetystä
- Backend käyttää frontendistä tullutta TO:ta tai fallbackina from_email

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:12:12 +02:00
83509fffc5 fix: käännä allekirjoitus-checkbox → "Käytä allekirjoitusta" (oletuksena päällä)
Checkbox nyt oletuksena rastittuna = allekirjoitus mukaan. Rastin poisto
poistaa allekirjoituksen viestistä.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:02:45 +02:00
2d2680483c feat: vastauspohjien hallinta asiakaspalvelu-tabissa + allekirjoitus-checkbox
- Vastauspohjat nyt hallittavissa Asiakaspalvelu-tabin kautta (kaikille käyttäjille)
- Uusi "Vastauspohjat" -nappi tikettilistan yläpalkissa
- CRUD: lisää, muokkaa, poista vastauspohjia tukitabin näkymässä
- "Älä käytä allekirjoitusta" -checkbox vastauslomakkeessa (oletuksena päällä)
- Backend: no_signature-parametri estää allekirjoituksen liittämisen
- Poistettu orpo profiili-vastauspohjien JS-koodi

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 21:51:56 +02:00
f6e11f8426 feat: oma profiili -toiminto + placeholder-siivous + poista fix-skriptit
- Lisätty "Oma profiili" -nappi headeriin (⚙ + nimen klikkaus)
- Profiili-modaali: muokkaa nimi, sähköposti, salasana, allekirjoitukset
- Uusi profile_update API-endpoint (vaatii vain kirjautumisen)
- check_auth palauttaa nyt myös email-kentän
- Siivottu kaikki yrityskohtaiset placeholder-tekstit geneerisiksi
  (cuitunet.fi → yritys.fi, Kauppakatu → Esimerkkikatu, jne.)
- Poistettu väliaikaiset fix_role.php ja fix_saatavuus.php

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 21:38:32 +02:00
f6602fb81f feat: tiketin asiakas-automaattitunnistus + lisää liidi -nappi
- Kun tiketti avataan, tarkistetaan lähettäjän sähköposti
  asiakasrekisteristä (sahkoposti + laskutussahkoposti)
- Jos asiakas löytyy → linkitetään automaattisesti + vihreä badge
- Jos ei löydy → näytetään "Lisää liidi" -nappi lähettäjätietojen
  vieressä, joka avaa liidilomakkeen esitäytetyillä tiedoilla
  (yhteyshenkilö, sähköposti, muistiinpanot)
- Jo linkitetyllä tiketillä näytetään vihreä asiakas-badge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 21:23:05 +02:00
0029256f03 temp: fix_saatavuus.php — korjaa API-avain ja CORS cuitunet.fi:lle
Poista palvelimelta käytön jälkeen!

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:57:37 +02:00
b7e50042b5 feat: admin näkee oman yrityksen käyttäjät
- Käyttäjät-nappi näkyy nyt myös admin-roolille
- Admin näkee/hallitsee vain oman yrityksensä käyttäjiä
- Admin voi luoda admin/user-rooleja (ei superadmin)
- Admin ei voi poistaa/muokata superadmineja
- Superadmin-vaihtoehto piilotettu rooli-dropdownista adminilta
- Yritysoikeudet-osio piilotettu adminilta (lisätään automaattisesti)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:26:53 +02:00
df42fbc917 temp: fix_role.php — korjaa admin → superadmin rooli
Poista palvelimelta käytön jälkeen!

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:22:17 +02:00
9140c912cd feat: Tekniikka-moduuli sub-tabeilla (Laitteet + Sijainnit + IPAM)
- Laitteet-tabi → Tekniikka (sub-tabit: Laitteet, Sijainnit, IPAM)
- Sijainnit siirretty omaksi taulukkonäkymäksi (+ "Lisää sijainti" laitteiden yhteydessä)
- Uusi IPAM-näkymä: IP-osoitteet, subnetit ja VLANit hallintaan
- IPAM: tyyppi (subnet/vlan/ip), verkko, VLAN-nro, sijainti, tila, asiakas
- Sub-tab-tyylit ja logiikka
- Yhteensopivuus: vanha 'devices' moduuli → 'tekniikka'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:18:56 +02:00
e37da2b40d fix: piilota nimi/subtitle login-sivulta kun logo on käytössä
Sama logiikka kuin headerissa — kun yrityksellä on logo,
pelkkä logo riittää eikä tekstejä näytetä.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:38:58 +02:00
03655956ac feat: asiakasyhteyksiin erilliset VLAN/laite/portti/IP-kentät
Korvattu yleinen lisätiedot-tekstikenttä neljällä erillisellä
kentällä (vlan, laite, portti, ip) jotta tiedoista voi hakea
ja filtteröidä tarkemmin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:26:22 +02:00
c6e68fd1e3 feat: lisätiedot-kenttä asiakasyhteyksiin (kytkin, IP, VLAN yms.)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:09:45 +02:00
18d378be63 feat: Laitteet-moduuli (inventaario) + sijaintien hallinta + login-fix
- Uusi "Laitteet" välilehti navigaatiossa (devices-moduuli)
  - Taulukko: Nimi, Hallintaosoite, Serial, Sijainti, Funktio, Tyyppi, Malli, Ping
  - Lisää/muokkaa/poista laitteita modaali-lomakkeella
  - Hakupalkki suodattaa kaikista kentistä
  - Ping-check täppä valmiina tulevaa toteutusta varten
- Sijainnit (Sites) -hallinta yrityksen asetuksissa
  - Lisää/muokkaa/poista sijainteja (toimipisteet, konesalit)
  - Sijainnit näkyvät laitelomakkeen dropdownissa
- Laitteet-moduuli lisätty moduulijärjestelmään (checkbox yritysasetuksissa)
- DB: sites + devices taulut, CRUD-funktiot
- Fix: Login-näkymä ei enää vilku refreshissä (piilotettu oletuksena)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:00:26 +02:00
a135aaaaef feat: moduulijärjestelmä + käyttäjäroolit + suhteellinen aika
- Moduulijärjestelmä: yrityskohtaiset tabit (customers, support, leads, archive,
  changelog, settings) valittavissa checkboxeina yrityksen asetuksissa
- Käyttäjäroolit: superadmin (pääkäyttäjä), admin (yritysadmin), user (käyttäjä)
  - Superadmin: kaikki oikeudet kuten ennen
  - Yritysadmin: muokkaa oman yrityksen asetuksia, moduuleita, postilaatikoita
  - Käyttäjä: peruskäyttö ilman hallintaoikeuksia
- Päivitetty-kenttä näyttää suhteellista aikaa (15min sitten, 2h sitten, 3pv sitten)
- DB: enabled_modules sarake companies-tauluun, role ENUM laajennettu
- Automaattinen migraatio: vanhat admin → superadmin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:42:07 +02:00
86ffcc88de fix: include priority field in ticket list API response
Priority was missing from the tickets list endpoint,
so colors weren't showing in the ticket table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:08:53 +02:00
19d94f8c19 fix: priority color takes precedence over status color in ticket list
Urgent (red) and tärkeä (orange) row colors now override
the "käsittelyssä" green highlight so priority is always visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:02:42 +02:00
4ce9cefa6a refactor: move priority emails to customer card
Priority emails are now per-customer, not per-company.
Each customer can have a list of email addresses that
automatically elevate ticket priority to "tärkeä" when
they send email. Field added to customer form under
"Lisätiedot" section.

Removed separate priority_emails settings from API/rules tabs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:00:10 +02:00
8485da8cbf feat: ticket reply improvements + priority + templates + Telegram
Reply form:
- Mailbox/sender selection dropdown (choose which email to reply from)
- CC field (auto-filled from incoming email CC, editable)
- Reply templates dropdown (quick insert pre-made responses)

Priority system:
- Three levels: normaali, tärkeä, urgent
- Priority dropdown in ticket detail view
- Priority-based sorting (urgent/tärkeä always on top)
- Visual indicators in ticket list (colored rows, emoji badges)
- Priority emails: per-company email list that auto-sets "tärkeä"

Response templates:
- CRUD management in Settings tab
- Dropdown selector in reply form
- Templates insert into textarea

Telegram alerts:
- Bot token + chat ID configuration in Settings
- Test button to verify connection
- Auto-alert on urgent tickets (both manual and from email fetch)
- Alert on priority email matches

Database changes:
- New tables: reply_templates, customer_priority_emails
- New columns: tickets.cc, tickets.priority
- ALTER TABLE migration in initDatabase()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:42:05 +02:00
3b7def1186 ui: hide header text when logo is set — logo is enough
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:29:13 +02:00
a0ee98cc9b ui: simplify header with logo, auto-refresh on by default
- When company logo is set, show only "Hallintapaneeli" without
  company name (logo identifies the company)
- Ticket auto-refresh checkbox is checked by default
- Auto-refresh starts when switching to support tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:25:46 +02:00
351ed70c6d ui: move theme color to nav tab bar, white header
Header is now white with neutral text colors.
Nav tab bar uses primary-color background with white text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:24:47 +02:00
ac5d2db711 cleanup: remove gdcheck.php - all extensions confirmed working
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:19:32 +02:00
d2ca790e32 feat: auto-extract color from logo + PHP extension check
Added extractDominantColor() JS function that picks the dominant
color from uploaded logo and suggests it as theme color.
Updated gdcheck.php to show all needed extensions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:19:08 +02:00
9797fda7b7 temp: check GD availability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:17:11 +02:00
caf0ce8aa2 ui: white header bar with primary color accents
Changed header from colored gradient background to clean white
with primary-color text, border-bottom accent line, and updated
button styles. Logos now display nicely against white background.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:15:43 +02:00
d8de69b9b9 fix: handle missing fileinfo extension for logo upload
finfo_open() is not available on CloudLinux alt-php84.
Now validates by file extension first, and only uses finfo
if the extension is available. Falls back gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:09:50 +02:00
b4b64fffcc temp: full logo upload test with form
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:07:32 +02:00
c3f2c3dbfa temp: filesystem permission check for logo upload
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:04:45 +02:00
3cfd80ad27 temp: diagnostic script for logo upload
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:03:25 +02:00
0605b646cf fix: auto-create company logo directory on upload
With MySQL migration, data/companies/{id}/ directories may not exist.
Now creates directory automatically instead of returning 404.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:59:49 +02:00
c8dce63f6e fix: use domain-based branding in check_auth response
check_auth was returning branding based on active company with
wrong field name (company_nimi instead of nimi), causing Noxus Intra
to show instead of company name on refresh. Now uses dbGetBranding()
with the request domain, same as the branding endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:56:52 +02:00
6ae25006b8 data: add intra.empor.fi domain for Empor
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:45:46 +02:00
f16d923b8b temp: add Empor domain fix script
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:45:13 +02:00
3d37abe6cf data: add intra.web1.fi domain and subtitle for Web1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:43:58 +02:00
e118513f64 cleanup: remove fix_domains.php after use
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:43:25 +02:00
c7d3ee1e70 temp: add fix_domains.php to set Web1 domain and branding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:42:44 +02:00
14cdfafd40 feat: domain-based login restriction
Users can only log in from domains belonging to their assigned company.
E.g. cuitunet users can only log in via intra.cuitunet.fi.
Admin users can still log in from any domain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:36:05 +02:00
1fa366d3ff feat: add ?reset parameter to migrate.php for clean re-run
Drops all tables (with FK checks disabled) before recreating.
Use: migrate.php?reset=1 or php migrate.php --reset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:28:42 +02:00
b074b7db28 fix: add unicode flag to named param regex for ö/ä chars
Column name yhteyshenkilö contains ö which \w doesn't match
without the /u flag. This caused SQL syntax errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:26:44 +02:00
8a630508f4 fix: add DEFAULT CHARSET=utf8mb4 to all tables
Foreign key constraints fail if charset doesn't match between
referencing and referenced tables. Added utf8mb4 to user_companies,
reset_tokens, and login_attempts tables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:24:25 +02:00
796e1b3072 feat: rewrite db.php from PDO to MySQLi
PDO extension was not available on CloudLinux/alt-php84 server.
MySQLi is available, so rewrote entire database layer to use it.

Added helper functions (_dbRun, _dbFetchAll, _dbFetchOne, etc.)
that handle named parameter conversion and type binding automatically.
All public db*() function signatures remain identical.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:04:14 +02:00
438a9b5070 temp: phpcheck to verify PDO after Plesk change
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:57:35 +02:00
a75ba19fe5 cleanup: remove phpcheck.php diagnostic script
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:28:01 +02:00
1a18da2430 temp: add phpcheck.php to diagnose PDO availability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:26:51 +02:00