Commit Graph

190 Commits

Author SHA1 Message Date
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
b15efa1758 cleanup: remove setup_config.php after use
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:25:37 +02:00
42571e46f3 temp: add setup_config.php to create db_config.php on server
Will be removed immediately after use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:24:20 +02:00
2b8e053e52 debug: add error display to migrate.php to see what fails
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:23:35 +02:00
e540ec0448 fix: split initDatabase() into separate exec() calls per table
MySQL/PDO doesn't support multiple CREATE TABLE statements in a single
exec() call. Split into an array of individual statements with a loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:15:55 +02:00
13e0d1255f JSON → MySQL migraatio: tietokantapohjainen datatallennus
Lisätty:
- db.php: PDO-tietokantakerros (kaikki CRUD-funktiot)
- migrate.php: JSON → MySQL migraatioskripti
- db_config.php lisätty .gitignore:en (sisältää tunnukset)

Muutettu:
- api.php: kaikki JSON load/save → db*() funktiot
- session.cookie_samesite: Strict → Lax (captcha-fix alias-domaineilla)
- Poistettu kaikki JSON-tiedosto I/O (paitsi tiedostoupload + logot)

Hyödyt:
- Git deploy ei enää ylikirjoita dataa
- Tiedostolukot ja transaktiot → ei korruptiota
- Parempi suorituskyky isoilla tietomäärillä

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:00:38 +02:00
c714f39bc5 Päivitä admin-salasana admin123 + kaikki tuotantodata
FTP:llä haettu data vanhalta intra.cuitunet.fi:
- 3 käyttäjää, admin-salasana resetoitu admin123
- 4 yritystä brändäyskentillä
- 35 CuituNet-asiakasta

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:31:46 +02:00
eed1ac5639 Migroi kaikki data vanhalta intra.cuitunet.fi -palvelimelta
FTP:llä haettu:
- 4 yritystä (CuituNet, Web1, Empor, Woima Services)
- 35 CuituNet-asiakasta + 1 liidi
- 1 Web1-asiakas
- 3 käyttäjää (admin, Jukka, ville)
- Brändäyskentät lisätty companies.json:iin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:26:11 +02:00
52bf1bd300 Päivitä CuituNetin data vanhalta palvelimelta (intra.cuitunet.fi)
Haettu API:n kautta: 2 asiakasta, 1 liidi.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:24:44 +02:00