Compare commits

..

4 Commits

Author SHA1 Message Date
Flatlogic Bot
47c0b35493 Stan przed edycją interfejsu procesów 2026-01-10 10:40:47 +00:00
Flatlogic Bot
cdd041c172 feat: Group functions in edit modal 2026-01-10 10:21:12 +00:00
Flatlogic Bot
3da7625d06 feat: Add phone and email to dashboard 2026-01-10 10:20:23 +00:00
Flatlogic Bot
2a8ad6701c feat: Refactor process dashboard UI 2026-01-10 10:19:38 +00:00
3 changed files with 130 additions and 69 deletions

View File

@ -2,6 +2,8 @@
require_once 'db/config.php'; require_once 'db/config.php';
if (isset($_GET['id'])) { if (isset($_GET['id'])) {
header('Content-Type: application/json');
try {
$person_id = $_GET['id']; $person_id = $_GET['id'];
$pdo = db(); $pdo = db();
@ -11,7 +13,12 @@ if (isset($_GET['id'])) {
$person = $stmt->fetch(PDO::FETCH_ASSOC); $person = $stmt->fetch(PDO::FETCH_ASSOC);
// Fetch all functions // Fetch all functions
$stmt = $pdo->query("SELECT id, name FROM functions ORDER BY display_order"); $stmt = $pdo->query("
SELECT f.id, f.name, bg.name as group_name
FROM functions f
LEFT JOIN bni_groups bg ON f.bni_group_id = bg.id
ORDER BY bg.display_order, f.display_order
");
$all_functions = $stmt->fetchAll(PDO::FETCH_ASSOC); $all_functions = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch person's functions // Fetch person's functions
@ -25,8 +32,11 @@ if (isset($_GET['id'])) {
'person_functions' => $person_functions 'person_functions' => $person_functions
]; ];
header('Content-Type: application/json');
echo json_encode($response); echo json_encode($response);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
exit; exit;
} }
?> ?>

View File

@ -1,4 +1,3 @@
body { body {
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f8f9fa; background-color: #f8f9fa;
@ -99,3 +98,45 @@ body {
width: 95%; width: 95%;
max-width: 1400px; max-width: 1400px;
} }
.status-dot {
height: 12px;
width: 12px;
border-radius: 50%;
display: inline-block;
margin-left: 4px;
}
.person-cell {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
}
.person-name {
font-weight: bold;
}
.person-details {
font-size: 0.75rem;
color: #6c757d;
}
.person-details .person-group {
font-weight: bold;
color: #198754;
}
.person-actions {
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
}
.status-dots {
display: flex;
justify-content: flex-end;
margin-bottom: 0.25rem;
}

View File

@ -121,6 +121,16 @@ $bni_groups = $stmt_bni_groups->fetchAll(PDO::FETCH_ASSOC);
$spotkania_cols = $stmt_meetings->fetchAll(PDO::FETCH_ASSOC); $spotkania_cols = $stmt_meetings->fetchAll(PDO::FETCH_ASSOC);
?> ?>
<div class="mb-3">
<label for="groupFilter" class="form-label">Filter by Group</label>
<select class="form-select" id="groupFilter">
<option value="">All Groups</option>
<?php foreach ($bni_groups as $group): ?>
<option value="<?= $group['id'] ?>"><?= htmlspecialchars($group['name']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-sm"> <table class="table table-bordered table-sm">
<thead class="table-light"> <thead class="table-light">
@ -148,27 +158,28 @@ $bni_groups = $stmt_bni_groups->fetchAll(PDO::FETCH_ASSOC);
</thead> </thead>
<tbody> <tbody>
<?php foreach ($people as $person): ?> <?php foreach ($people as $person): ?>
<tr> <tr data-group-id="<?= $person['bni_group_id'] ?>">
<td class="text-center align-middle"><input type="checkbox" class="person-checkbox" name="person_ids[]" value="<?= $person['id'] ?>"></td> <td class="text-center align-middle"><input type="checkbox" class="person-checkbox" name="person_ids[]" value="<?= $person['id'] ?>"></td>
<td> <td class="person-cell">
<div> <div class="person-main">
<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?> <div class="person-name"><?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?></div>
<?php if ($person['role'] === 'member'): ?> <div class="person-details">
<div class="d-inline-block ms-2"> <span class="d-block"><?= htmlspecialchars($person['companyName']) ?></span>
<i class="bi <?= !empty($person['gains_sheet_path']) ? 'bi-file-earmark-check text-success' : 'bi-file-earmark-x text-danger' ?>" title="GAINS Sheet"></i> <span class="d-block"><?= htmlspecialchars($person['industry'] ?? '') ?></span>
<i class="bi <?= !empty($person['top_wanted_contacts_path']) ? 'bi-file-earmark-check text-success' : 'bi-file-earmark-x text-danger' ?>" title="Top Wanted Contacts"></i> <span><?= htmlspecialchars(ucfirst($person['role'])) ?></span>
<i class="bi <?= !empty($person['top_owned_contacts_path']) ? 'bi-file-earmark-check text-success' : 'bi-file-earmark-x text-danger' ?>" title="Top Owned Contacts"></i>
</div>
<?php endif; ?>
<br>
<small class="text-muted"><?= htmlspecialchars($person['companyName']) ?></small>
<br>
<small class="text-info fw-bold"><?= htmlspecialchars(ucfirst($person['role'])) ?></small>
<?php if ($person['role'] === 'member' && !empty($person['bni_group_name'])): ?> <?php if ($person['role'] === 'member' && !empty($person['bni_group_name'])): ?>
<br><small class="text-success fw-bold">Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></small> <span class="person-group">, Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></span>
<?php endif; ?>
</div>
</div>
<div class="person-actions">
<div class="status-dots">
<?php if ($person['role'] === 'member'): ?>
<span class="status-dot <?= !empty($person['gains_sheet_path']) ? 'bg-success' : 'bg-danger' ?>" title="GAINS Sheet"></span>
<span class="status-dot <?= !empty($person['top_wanted_contacts_path']) ? 'bg-success' : 'bg-danger' ?>" title="Top Wanted Contacts"></span>
<span class="status-dot <?= !empty($person['top_owned_contacts_path']) ? 'bg-success' : 'bg-danger' ?>" title="Top Owned Contacts"></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="mt-1">
<button class="btn btn-sm btn-secondary edit-btn" data-bs-toggle="modal" data-bs-target="#editPersonModal" <button class="btn btn-sm btn-secondary edit-btn" data-bs-toggle="modal" data-bs-target="#editPersonModal"
data-person-id="<?= $person['id'] ?>" data-person-id="<?= $person['id'] ?>"
data-person-name="<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?>"> data-person-name="<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?>">
@ -594,15 +605,31 @@ document.addEventListener('DOMContentLoaded', function () {
const functionsSelect = document.getElementById('editRoles'); const functionsSelect = document.getElementById('editRoles');
functionsSelect.innerHTML = ''; // Clear existing options functionsSelect.innerHTML = ''; // Clear existing options
data.all_functions.forEach(func => { // Group functions by group_name
const groupedFunctions = data.all_functions.reduce((acc, func) => {
const groupName = func.group_name || 'Other';
if (!acc[groupName]) {
acc[groupName] = [];
}
acc[groupName].push(func);
return acc;
}, {});
// Populate select with optgroups
for (const groupName in groupedFunctions) {
const optgroup = document.createElement('optgroup');
optgroup.label = groupName;
groupedFunctions[groupName].forEach(func => {
const option = document.createElement('option'); const option = document.createElement('option');
option.value = func.id; option.value = func.id;
option.textContent = func.name; option.textContent = func.name;
if (data.person_functions.includes(func.id)) { if (data.person_functions.map(String).includes(String(func.id))) {
option.selected = true; option.selected = true;
} }
functionsSelect.appendChild(option); optgroup.appendChild(option);
}); });
functionsSelect.appendChild(optgroup);
}
}); });
}); });
} }
@ -698,24 +725,7 @@ document.addEventListener('DOMContentLoaded', function () {
editMemberOnlyFields.style.display = isMember ? 'block' : 'none'; editMemberOnlyFields.style.display = isMember ? 'block' : 'none';
}); });
// Adjust edit modal population
if(editPersonModal) {
editPersonModal.addEventListener('show.bs.modal', function (event) {
// ... (existing code) ...
fetch('_get_person_details.php?id=' + personId)
.then(response => response.json())
.then(data => {
// ... (existing population code) ...
document.getElementById('editRole').value = data.person.role;
document.getElementById('editBniGroup').value = data.person.bni_group_id || '';
// Trigger change to show/hide group div
editRoleSelect.dispatchEvent(new Event('change'));
// ... (rest of the population code) ...
});
});
}
}); });
</script> </script>