( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Database connection
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require 'brandteams/config.php';
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch teams from the database
$sql = "SELECT * FROM brand_teams";
$result = $conn->query($sql);
$teams = [];
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$teams[] = $row;
}
}
// Fetch users from the database (assuming you have a users table)
/*$userSql = "SELECT * FROM users where catalogid=152";
$userResult = $conn->query($userSql);
$users = [];
if ($userResult->num_rows > 0) {
while ($row = $userResult->fetch_assoc()) {
$users[] = $row;
}
}*/
$conn->close();
?>
<link rel="stylesheet" href="assets/timeline/assets/css/style.css?<?php echo rand(11, 4444); ?>">
<link rel="stylesheet" href="assets/vendor/css/pages/app-academy.css"/>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<div class="app-academy">
<div class="card p-0 mb-6">
<div class="card-body d-flex flex-column flex-md-row justify-content-between p-0 pt-6">
<div class="app-academy-md-25 card-body py-0 pt-6 ps-12">
<img src="assets/img/illustrations/bulb-light.png"
class="img-fluid app-academy-img-height scaleX-n1-rtl" alt="Bulb in hand"
data-app-light-img="illustrations/bulb-light.png" data-app-dark-img="illustrations/bulb-dark.png"
height="90"/>
</div>
<div class="app-academy-md-50 card-body d-flex align-items-md-center flex-column text-md-center mb-6 py-6">
<span class="card-title mb-4 px-md-12 h4">
🎨 Empower Your Team to Collaborate, Share, &
<span class="text-primary text-nowrap"> Succeed</span>.
</span>
<p class="mb-4">
Bring your ideas to life with seamless collaboration. Share designs, craft winning strategies, and
map out journeys that inspire.
</p><!-- Notification Div -->
<div id="notification" class="alert d-none" role="alert"></div>
<div class="align-items-center justify-content-between app-academy-md-80">
<form id="teamForm" style="all: unset; align-items-center">
<div class="d-flex align-items-center justify-content-between app-academy-md-80">
<input type="search" id="teamName" placeholder="👉 Create your team!"
class="form-control me-4">
<button type="submit" class="btn btn-primary btn-icon">
<i class="bx bx-user-plus bx-md"></i>
</button>
</div>
</form>
</div>
</div>
<div class="app-academy-md-25 d-flex align-items-end justify-content-end">
<img src="assets/img/illustrations/pencil-rocket.png" alt="pencil rocket" height="180"
class="scaleX-n1-rtl"/>
</div>
</div>
</div>
</div>
<div class="card-body"> <div class="row gy-6 mb-6">
<!--<div class="list-group-item"><a href="https://www.thebrand.ai/brandteams/index.php"> Teams home</a></div>
<div class="list-group-item"><a href="https://www.thebrand.ai/brandteams/share.php"> Share Content With
Teams</a></div>
<div class="list-group-item"><a href="https://www.thebrand.ai/brandteams/sharewithuser.php"> Share Content
With user</a></div>
<div class="list-group-item"><a href="https://www.thebrand.ai/brandteams/brand_folders.php"> Manage
Folders</a></div>-->
<div class="">
<div class="btn-group"><a href="https://www.thebrand.ai/insights/dashboard?feature=teams#"><button type="button" class="btn btn-info"><i class="bx bx-home bx-md"></i></button> </a> </div>
<!-- Marketing Dropdown -->
<div class="btn-group">
<a href="https://www.thebrand.ai/insights/dashboard?feature=teams&page=shareteams"> <button type="button" class="btn btn-outline-dark">Share With Teams</button></a>
</div>
<div class="btn-group">
<a href="https://www.thebrand.ai/insights/dashboard?feature=teams&page=shareusers"> <button type="button" class="btn btn-outline-dark">Share With user</button></a>
</div>
<div class="btn-group">
<a href="https://www.thebrand.ai/insights/dashboard?feature=teams&page=folders"> <button type="button" class="btn btn-outline-dark">Manage Folders</button></a>
</div>
</div>
</div></div>
<?php
if (!empty($_GET["page"])) {?>
<?php if ($_GET["page"] == "shareteams") {include "brandteams/share.php"; } ?>
<?php if ($_GET["page"] == "shareusers") { include "brandteams/sharewithuser.php";} ?>
<?php if ($_GET["page"] == "folders") { include "brandteams/brand_folders.php";} ?>
<?php if ($_GET["page"] == "view_team") { include "brandteams/view_team.php";} ?>
<?php } ?>
<?php
if (empty($_GET["page"])) {?>
<!-- Users List Table -->
<div class="card"><div class="card-body">
<div class="row justify-content-between mb-4">
<div class="card-title mb-5 me-1">
<h3 class="mb-0" style="text-transform: capitalize">My Teams</h3>
</div>
<div id="teamsList" class="list-group">
<?php foreach ($teams as $team): ?>
<div class="list-group-item d-flex justify-content-between align-items-center">
<?= htmlspecialchars($team['name']) ?>
<div>
<button class="btn btn-warning btn-sm update-team" data-id="<?= $team['id'] ?>">Update</button>
<button class="btn btn-danger btn-sm delete-team" data-id="<?= $team['id'] ?>">Delete</button>
<button class="btn btn-info btn-sm add-member" data-id="<?= $team['id'] ?>" data-toggle="modal"
data-target="#addMemberModal">Add Member
</button>
<a href="https://www.thebrand.ai/insights/dashboard?feature=teams&page=view_team&team_id=<?= $team['id'] ?>">
<button class="btn btn-info btn-sm add-member">View Team</button>
</a>
<a href="https://www.thebrand.ai/insights/dashboard?feature=teams&page=sharedteam&team_id=<?= $team['id'] ?>&userid=2">
<button class="btn btn-info btn-sm add-member">View Content</button>
</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div> </div> </div>
<?php } ?>
<!-- Modal for adding user to team -->
<div class="modal fade" id="addMemberModal" tabindex="-1" role="dialog" aria-labelledby="addMemberModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addMemberModalLabel">Add User to Team</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="hidden" id="teamIdForMember">
<div class="form-group">
<label for="userSelect">Add Member</label>
<input type="text" id="userSelect" class="form-control" required placeholder="add email">
</div>
<div class="form-group">
<label for="roleSelect">Select Role</label>
<select id="roleSelect" class="form-control">
<!-- You can populate this with actual roles from your database -->
<!-- <option value="1">Admin</option>-->
<option value="2">Member</option>
<option value="3">Designer</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" id="saveMemberButton" class="btn btn-primary">Add Member</button>
</div>
</div>
</div>
</div>
<!-- Modal for updating team -->
<div class="modal fade" id="updateTeamModal" tabindex="-1" role="dialog" aria-labelledby="updateTeamModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateTeamModalLabel">Update Team Name</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="text" id="updateTeamName" class="form-control" required>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss='modal'>Close</button>
<button type='button' id='saveUpdateButton' class='btn btn-primary'>Save changes</button>
</div>
</div>
</div>
</div>
<script src='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js'></script>
<script>
// Existing jQuery code...
$(document).ready(function () {
$('#teamForm').on('submit', function (e) {
e.preventDefault();
const teamName = $('#teamName').val();
if (teamName === '') { return;
}
$.ajax({
url: 'brandteams/process/create_team.php',
type: 'POST',
data: {name: teamName},
success: function (response) {
const data = JSON.parse(response);
$('#notification').removeClass('d-none');
if (data.success) {
$('#notification').addClass('alert-success').text('Team created successfully!');
$('#teamsList').append('<div class=\"list-group-item\">' + data.team.name + '</div>');
$('#teamName').val(''); // Clear input field
window.location.href = 'https://www.thebrand.ai/insights/dashboard?feature=teams';
} else {
$('#notification').addClass('alert-danger').text(data.message);
}
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
},
error: function () {
$('#notification').removeClass('d-none').addClass('alert-danger').text('Error creating team.');
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
}
});
});
// Update Team
$(document).on('click', '.update-team', function () {
const teamId = $(this).data('id');
const currentName = $(this).closest('.list-group-item').contents().filter(function () {
return this.nodeType === 3;
}).text().trim();
$('#updateTeamName').val(currentName);
$('#saveUpdateButton').data('id', teamId); // Store team ID in button
$('#updateTeamModal').modal('show');
});
$('#saveUpdateButton').on('click', function () {
const teamId = $(this).data('id');
const updatedName = $('#updateTeamName').val();
$.ajax({
url: 'brandteams/process/update_team.php',
type: 'POST',
data: {id: teamId, name: updatedName},
success: function (response) {
const data = JSON.parse(response);
if (data.success) {
$('#notification').removeClass('d-none').addClass('alert-success').text('Team updated successfully!');
$('button[data-id="' + teamId + '"]').closest('.list-group-item').contents().filter(function () {
return this.nodeType === 3;
}).replaceWith(data.team.name + ' ');
$('#updateTeamModal').modal('hide');
} else {
$('#notification').removeClass('d-none').addClass('alert-danger').text(data.message);
}
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
},
error: function () {
$('#notification').removeClass('d-none').addClass('alert-danger').text('Error updating team.');
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
}
});
});
// Delete Team
$(document).on('click', '.delete-team', function () {
const teamId = $(this).data('id');
if (confirm("Are you sure you want to delete this team?")) {
$.ajax({
url: 'brandteams/process/delete_team.php',
type: 'POST',
data: {id: teamId},
success: function (response) {
const data = JSON.parse(response);
if (data.success) {
$('#notification').removeClass('d-none').addClass('alert-success').text('Team deleted successfully!');
$('button[data-id="' + teamId + '"]').closest('.list-group-item').remove();
} else {
$('#notification').removeClass('d-none').addClass('alert-danger').text(data.message);
}
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
},
error: function () {
$('#notification').removeClass('d-none').addClass('alert-danger').text('Error deleting team.');
setTimeout(function () {
$('#notification').addClass('d-none');
$('#notification').removeClass('alert-success alert-danger');
}, 3000);
}
});
}
});
// Add Member
$(document).on('click', '.add-member', function () {
const teamId = $(this).data('id');
$('#teamIdForMember').val(teamId); // Store team ID in hidden input
});
$('#saveMemberButton').on('click', function () {
const teamId = $('#teamIdForMember').val();
const userId = $('#userSelect').val();
const roleId = $('#roleSelect').val();
$.ajax({
url: 'brandteams/process/add_member.php',
type: 'POST',
data: {team_id: teamId, user_id: userId, role_id: roleId},
success: function (response) {
const data = JSON.parse(response);
if (data.success) {
$('#notification')
.removeClass('d-none')
.addClass('alert-success')
.text('User added to team successfully!');
$('#addMemberModal').modal('hide');
} else {
$('#notification')
.removeClass('d-none')
.addClass('alert-danger')
.text(data.message);
}
setTimeout(function () {
$('#notification')
.addClass('d-none')
.removeClass('alert-success alert-danger');
}, 3000);
},
error: function () {
$('#notification')
.removeClass('d-none')
.addClass('alert-danger')
.text('Error adding member.');
setTimeout(function () {
$('#notification')
.addClass('d-none')
.removeClass('alert-success alert-danger');
}, 3000);
}
});
});
});
</script>
<script src="assets/timeline/assets/js/util.js"></script>
<!-- util functions included in the CodyHouse framework -->
<script src="assets/timeline/assets/js/swipe-content.js"></script>
<!-- A Vanilla JavaScript plugin to detect touch interactions -->
<script src="assets/timeline/assets/js/main.js"></script>