Stan przed edycją interfejsu procesów
This commit is contained in:
parent
cdd041c172
commit
47c0b35493
@ -2,36 +2,41 @@
|
|||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
if (isset($_GET['id'])) {
|
if (isset($_GET['id'])) {
|
||||||
$person_id = $_GET['id'];
|
|
||||||
$pdo = db();
|
|
||||||
|
|
||||||
// Fetch person details
|
|
||||||
$stmt = $pdo->prepare("SELECT * FROM people WHERE id = ?");
|
|
||||||
$stmt->execute([$person_id]);
|
|
||||||
$person = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
// Fetch all functions
|
|
||||||
$stmt = $pdo->query("
|
|
||||||
SELECT f.id, f.name, bg.name as group_name
|
|
||||||
FROM functions f
|
|
||||||
LEFT JOIN bni_groups bg ON f.group_id = bg.id
|
|
||||||
ORDER BY f.display_order
|
|
||||||
");
|
|
||||||
$all_functions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
// Fetch person's functions
|
|
||||||
$stmt = $pdo->prepare("SELECT function_id FROM user_functions WHERE user_id = ?");
|
|
||||||
$stmt->execute([$person_id]);
|
|
||||||
$person_functions = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
|
||||||
|
|
||||||
$response = [
|
|
||||||
'person' => $person,
|
|
||||||
'all_functions' => $all_functions,
|
|
||||||
'person_functions' => $person_functions
|
|
||||||
];
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($response);
|
try {
|
||||||
|
$person_id = $_GET['id'];
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Fetch person details
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM people WHERE id = ?");
|
||||||
|
$stmt->execute([$person_id]);
|
||||||
|
$person = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Fetch all functions
|
||||||
|
$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);
|
||||||
|
|
||||||
|
// Fetch person's functions
|
||||||
|
$stmt = $pdo->prepare("SELECT function_id FROM user_functions WHERE user_id = ?");
|
||||||
|
$stmt->execute([$person_id]);
|
||||||
|
$person_functions = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'person' => $person,
|
||||||
|
'all_functions' => $all_functions,
|
||||||
|
'person_functions' => $person_functions
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|||||||
90
index.php
90
index.php
@ -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,39 +158,33 @@ $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"> </span>
|
<?php if ($person['role'] === 'member' && !empty($person['bni_group_name'])): ?>
|
||||||
<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"> </span>
|
<span class="person-group">, Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></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"> </span>
|
<?php endif; ?>
|
||||||
<?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'])): ?>
|
|
||||||
<small class="text-success fw-bold d-inline">, Grupa: <?= htmlspecialchars($person['bni_group_name']) ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
<button class="btn btn-sm btn-secondary edit-btn" data-bs-toggle="modal" data-bs-target="#editPersonModal"
|
<div class="person-actions">
|
||||||
data-person-id="<?= $person['id'] ?>"
|
<div class="status-dots">
|
||||||
data-person-name="<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?>">
|
<?php if ($person['role'] === 'member'): ?>
|
||||||
Edit
|
<span class="status-dot <?= !empty($person['gains_sheet_path']) ? 'bg-success' : 'bg-danger' ?>" title="GAINS Sheet"></span>
|
||||||
</button>
|
<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>
|
</div>
|
||||||
|
<button class="btn btn-sm btn-secondary edit-btn" data-bs-toggle="modal" data-bs-target="#editPersonModal"
|
||||||
|
data-person-id="<?= $person['id'] ?>"
|
||||||
|
data-person-name="<?= htmlspecialchars($person['firstName'] . ' ' . $person['lastName']) ?>">
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user