Stan przed edycją interfejsu procesów

This commit is contained in:
Flatlogic Bot 2026-01-10 10:40:47 +00:00
parent cdd041c172
commit 47c0b35493
3 changed files with 112 additions and 84 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();
@ -14,8 +16,8 @@ if (isset($_GET['id'])) {
$stmt = $pdo->query(" $stmt = $pdo->query("
SELECT f.id, f.name, bg.name as group_name SELECT f.id, f.name, bg.name as group_name
FROM functions f FROM functions f
LEFT JOIN bni_groups bg ON f.group_id = bg.id LEFT JOIN bni_groups bg ON f.bni_group_id = bg.id
ORDER BY f.display_order ORDER BY bg.display_order, f.display_order
"); ");
$all_functions = $stmt->fetchAll(PDO::FETCH_ASSOC); $all_functions = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -30,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,40 +158,34 @@ $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 style="position: relative;"> <td class="person-cell">
<div class="d-flex justify-content-between align-items-center"> <div class="person-main">
<div> <div class="person-name"><?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?></div>
<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?> <div class="person-details">
<span class="d-block"><?= htmlspecialchars($person['companyName']) ?></span>
<div class="position-absolute top-0 end-0 p-1"> <span class="d-block"><?= htmlspecialchars($person['industry'] ?? '') ?></span>
<?php if ($person['role'] === 'member'): ?> <span><?= htmlspecialchars(ucfirst($person['role'])) ?></span>
<span class="badge rounded-circle <?= !empty($person['gains_sheet_path']) ? 'bg-success' : 'bg-danger' ?>" style="width: 10px; height: 10px; display: inline-block;" title="GAINS Sheet">&nbsp;</span>
<span class="badge rounded-circle <?= !empty($person['top_wanted_contacts_path']) ? 'bg-success' : 'bg-danger' ?>" style="width: 10px; height: 10px; display: inline-block;" title="Top Wanted Contacts">&nbsp;</span>
<span class="badge rounded-circle <?= !empty($person['top_owned_contacts_path']) ? 'bg-success' : 'bg-danger' ?>" style="width: 10px; height: 10px; display: inline-block;" title="Top Owned Contacts">&nbsp;</span>
<?php endif; ?>
</div>
<div style="font-size: 0.8rem;">
<small class="text-muted d-block"><?= htmlspecialchars($person['companyName']) ?></small>
<small class="text-muted d-block"><?= htmlspecialchars($person['industry'] ?? '') ?></small>
<small class="text-muted d-block">Tel: <?= htmlspecialchars($person['phone'] ?? '') ?></small>
<small class="text-muted d-block">Email: <?= htmlspecialchars($person['email'] ?? '') ?></small>
<small class="text-info fw-bold d-inline"><?= 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'])): ?>
<small class="text-success fw-bold d-inline">, Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></small> <span class="person-group">, Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </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; ?>
</div>
<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']) ?>">
Edit Edit
</button> </button>
</div> </div>
</div>
</td> </td>
<?php // Spotkania Columns ?> <?php // Spotkania Columns ?>
@ -601,10 +605,7 @@ document.addEventListener('DOMContentLoaded', function () {
const functionsSelect = document.getElementById('editRoles'); const functionsSelect = document.getElementById('editRoles');
functionsSelect.innerHTML = ''; // Clear existing options functionsSelect.innerHTML = ''; // Clear existing options
const functionsSelect = document.getElementById('editRoles'); // Group functions by group_name
functionsSelect.innerHTML = ''; // Clear existing options
// Group functions by group name
const groupedFunctions = data.all_functions.reduce((acc, func) => { const groupedFunctions = data.all_functions.reduce((acc, func) => {
const groupName = func.group_name || 'Other'; const groupName = func.group_name || 'Other';
if (!acc[groupName]) { if (!acc[groupName]) {
@ -614,11 +615,10 @@ document.addEventListener('DOMContentLoaded', function () {
return acc; return acc;
}, {}); }, {});
// Populate the select with optgroups // Populate select with optgroups
for (const groupName in groupedFunctions) { for (const groupName in groupedFunctions) {
const optgroup = document.createElement('optgroup'); const optgroup = document.createElement('optgroup');
optgroup.label = groupName; optgroup.label = groupName;
groupedFunctions[groupName].forEach(func => { groupedFunctions[groupName].forEach(func => {
const option = document.createElement('option'); const option = document.createElement('option');
option.value = func.id; option.value = func.id;
@ -628,7 +628,6 @@ document.addEventListener('DOMContentLoaded', function () {
} }
optgroup.appendChild(option); optgroup.appendChild(option);
}); });
functionsSelect.appendChild(optgroup); functionsSelect.appendChild(optgroup);
} }
}); });
@ -726,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>