Commit Graph

6 Commits

Author SHA1 Message Date
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
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
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