v1.7.0: refactor max_bot to flat structure, add VCF+UserModel+NLP history context, portal pages and proxy fixes
- Refactored max_bot from nested packages to flat module structure - Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets) - Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT) - Q1: Broadcast preview modal with 10s confirmation timer - Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary) - Q4: bot_settings showNotification(), editable max_bot_id - Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret - Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists() - Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py - Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings - Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py - Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
This commit is contained in:
@@ -81,14 +81,14 @@ if ($severityFilter) {
|
||||
$sql .= " AND i.severity = ?";
|
||||
$params[] = $severityFilter;
|
||||
}
|
||||
$sql .= " ORDER BY FIELD(i.severity,'P1','P2','P3'), i.created_at DESC";
|
||||
$sql .= " ORDER BY CASE i.severity WHEN 'P1' THEN 1 WHEN 'P2' THEN 2 WHEN 'P3' THEN 3 END, i.created_at DESC";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$incidents = $stmt->fetchAll();
|
||||
|
||||
$objects = $pdo->query("SELECT id, name FROM objects WHERE status='active' ORDER BY name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE is_active=1 ORDER BY full_name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE is_active ORDER BY full_name")->fetchAll();
|
||||
|
||||
$csrf = auth_csrf_token();
|
||||
require __DIR__ . '/../../inc/header.php';
|
||||
|
||||
@@ -81,14 +81,14 @@ if ($search) {
|
||||
$params[] = "%$search%";
|
||||
$params[] = "%$search%";
|
||||
}
|
||||
$sql .= " ORDER BY FIELD(t.priority,'P1','P2','P3','P4'), t.deadline ASC, t.created_at DESC";
|
||||
$sql .= " ORDER BY CASE t.priority WHEN 'P1' THEN 1 WHEN 'P2' THEN 2 WHEN 'P3' THEN 3 WHEN 'P4' THEN 4 END, t.deadline ASC, t.created_at DESC";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$tasks = $stmt->fetchAll();
|
||||
|
||||
$activeObjects = $pdo->query("SELECT id, name FROM objects WHERE status='active' ORDER BY name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE role IN ('engineer','technician') AND is_active=1 ORDER BY full_name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE role IN ('engineer','technician') AND is_active ORDER BY full_name")->fetchAll();
|
||||
|
||||
$csrf = auth_csrf_token();
|
||||
require __DIR__ . '/../../inc/header.php';
|
||||
|
||||
@@ -39,7 +39,7 @@ if (isset($_GET['remove'])) {
|
||||
}
|
||||
|
||||
$objects = $pdo->query("SELECT id, name FROM objects WHERE status='active' ORDER BY name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name, role FROM users WHERE role IN ('engineer','technician') AND is_active=1 ORDER BY full_name")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name, role FROM users WHERE role IN ('engineer','technician') AND is_active ORDER BY full_name")->fetchAll();
|
||||
|
||||
// Get active assignments
|
||||
$assignments = $pdo->query("
|
||||
|
||||
@@ -25,7 +25,7 @@ $stmt = $pdo->query("SELECT COUNT(*) FROM objects WHERE status='active'");
|
||||
$totalObjects = $stmt->fetchColumn();
|
||||
|
||||
// Engineer count
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM users WHERE role IN ('engineer','technician') AND is_active=1");
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM users WHERE role IN ('engineer','technician') AND is_active");
|
||||
$engineerCount = $stmt->fetchColumn();
|
||||
|
||||
// SLA compliance
|
||||
|
||||
@@ -28,15 +28,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
try {
|
||||
$oldVal = null;
|
||||
if ($id > 0) {
|
||||
$stmt = $pdo->prepare("SELECT `key`, `value` FROM formula_coefficients WHERE id=?");
|
||||
$stmt = $pdo->prepare('SELECT "key", "value" FROM formula_coefficients WHERE id=?');
|
||||
$stmt->execute([$id]);
|
||||
$old = $stmt->fetch();
|
||||
$oldVal = $old ? $old['value'] : null;
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE formula_coefficients SET `key`=?, `value`=?, `description`=?, `formula_ref`=?, `updated_by`=? WHERE id=?");
|
||||
$stmt = $pdo->prepare('UPDATE formula_coefficients SET "key"=?, "value"=?, "description"=?, "formula_ref"=?, "updated_by"=? WHERE id=?');
|
||||
$stmt->execute([$key, $value, $description, $formulaRef, $session['user_id'], $id]);
|
||||
} else {
|
||||
$stmt = $pdo->prepare("INSERT INTO formula_coefficients (`key`, `value`, `description`, `formula_ref`, `updated_by`) VALUES (?,?,?,?,?)");
|
||||
$stmt = $pdo->prepare('INSERT INTO formula_coefficients ("key", "value", "description", "formula_ref", "updated_by") VALUES (?,?,?,?,?)');
|
||||
$stmt->execute([$key, $value, $description, $formulaRef, $session['user_id']]);
|
||||
}
|
||||
$message = 'Коэффициент "' . htmlspecialchars($key) . '" сохранён.';
|
||||
@@ -50,7 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
}
|
||||
} elseif ($_POST['action'] === 'toggle') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
$stmt = $pdo->prepare("SELECT `key`, `is_active` FROM formula_coefficients WHERE id=?");
|
||||
$stmt = $pdo->prepare('SELECT "key", is_active FROM formula_coefficients WHERE id=?');
|
||||
$stmt->execute([$id]);
|
||||
$c = $stmt->fetch();
|
||||
if ($c) {
|
||||
@@ -83,7 +83,7 @@ if (isset($_GET['edit'])) {
|
||||
}
|
||||
|
||||
// Get all coefficients ordered by key
|
||||
$coeffs = $pdo->query("SELECT * FROM formula_coefficients ORDER BY `key`")->fetchAll();
|
||||
$coeffs = $pdo->query('SELECT * FROM formula_coefficients ORDER BY "key"')->fetchAll();
|
||||
|
||||
// Group by prefix
|
||||
$groups = [];
|
||||
|
||||
@@ -12,7 +12,7 @@ $pdo = getDB();
|
||||
$userId = $session['user_id'];
|
||||
|
||||
// Calculate KPI for each engineer
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE role IN ('engineer','technician') AND is_active=1")->fetchAll();
|
||||
$engineers = $pdo->query("SELECT id, full_name FROM users WHERE role IN ('engineer','technician') AND is_active")->fetchAll();
|
||||
$periodStart = date('Y-m-01');
|
||||
$periodEnd = date('Y-m-t');
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ if ($sessId) {
|
||||
$qItems = [];
|
||||
$qSections = [];
|
||||
if ($sessId) {
|
||||
$stmt = $pdo->prepare("SELECT * FROM questionnaire_items WHERE is_active=1 AND step=? ORDER BY sort_order, id");
|
||||
$stmt = $pdo->prepare("SELECT * FROM questionnaire_items WHERE is_active AND step=? ORDER BY sort_order, id");
|
||||
$stmt->execute([$step]);
|
||||
$qItems = $stmt->fetchAll();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ $stmt = $pdo->prepare("
|
||||
FROM tasks t
|
||||
JOIN objects o ON o.id = t.object_id
|
||||
WHERE t.assigned_to = ? AND t.status IN ('open','in_progress')
|
||||
ORDER BY FIELD(t.priority,'P1','P2','P3','P4'), t.deadline ASC
|
||||
ORDER BY CASE t.priority WHEN 'P1' THEN 1 WHEN 'P2' THEN 2 WHEN 'P3' THEN 3 WHEN 'P4' THEN 4 END, t.deadline ASC
|
||||
");
|
||||
$stmt->execute([$userId]);
|
||||
$myTasks = $stmt->fetchAll();
|
||||
|
||||
Reference in New Issue
Block a user