Skip to content

Commit

Permalink
User panel (#23)
Browse files Browse the repository at this point in the history
resolved merge conficts
  • Loading branch information
kamranzafar4343 authored Oct 1, 2024
2 parents 46caff1 + 6effd6f commit 8f2b905
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 226 deletions.
260 changes: 135 additions & 125 deletions box.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,118 +369,118 @@
<!-- ======= header ======= -->
<?php include 'headerfile.php'; ?>
<?php
include "config/db.php";
$role = $_SESSION['role'];
?>

<!-- ======= Sidebar ======= -->
<aside id="sidebar" class="sidebar">
<ul class="sidebar-nav" id="sidebar-nav">

<!-- Dashboard Link (Visible to all users) -->
<li class="nav-item">
<a class="nav-link collapsed" href="index.php">
<i class="ri-home-8-line"></i>
<span>Dashboard</span>
</a>
</li><!-- End Dashboard Nav -->

<?php if ($_SESSION['role'] == 'admin') { ?>
<!-- Admin-only Links -->
<li class="nav-item">
<a class="nav-link collapsed" href="Companies.php">
<i class="ri-building-4-line"></i><span>Companies</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Companies Nav -->

<li class="nav-item">
<a class="nav-link active" href="box.php">
<i class="ri-archive-stack-fill"></i><span>Boxes</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Boxes Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="showItems.php">
<i class="ri-shopping-cart-line"></i><span>Items</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Items Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="order.php">
<i class="ri-list-ordered"></i><span>Work Orders</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Work Orders Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="racks.php">
<i class="bi bi-box"></i><span>Racks</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Racks Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="store.php">
<i class="bi bi-shop"></i><span>Store</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Store Nav -->

<?php } else { ?>
<!-- User-only Links -->
<li class="nav-item">
<a class="nav-link active" href="box.php">
<i class="ri-archive-stack-fill"></i><span>Boxes</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Boxes Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="showItems.php">
<i class="ri-shopping-cart-line"></i><span>Items</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Items Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="order.php">
<i class="ri-list-ordered"></i><span>Work Orders</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Work Orders Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="racks.php">
<i class="bi bi-box"></i><span>Racks</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Racks Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="store.php">
<i class="bi bi-shop"></i><span>Store</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Store Nav -->
<?php } ?>


<li class="nav-heading">Pages</li>

<li class="nav-item">
<a class="nav-link collapsed" href="users-profile.php">
<i class="bi bi-person"></i><span>Profile</span>
</a>
</li><!-- End Profile Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="pages-login.php">
<i class="bi bi-box-arrow-right"></i><span>Login</span>
</a>
</li><!-- End Login Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="logout.php">
<i class="bi bi-box-arrow-left"></i><span>Logout</span>
</a>
</li><!-- End Logout Nav -->

</ul>
</aside>
<!--------------- End sidebar ------------------>
include "config/db.php";
$role = $_SESSION['role'];
?>

<!-- ======= Sidebar ======= -->
<aside id="sidebar" class="sidebar">
<ul class="sidebar-nav" id="sidebar-nav">

<!-- Dashboard Link (Visible to all users) -->
<li class="nav-item">
<a class="nav-link collapsed" href="index.php">
<i class="ri-home-8-line"></i>
<span>Dashboard</span>
</a>
</li><!-- End Dashboard Nav -->

<?php if ($_SESSION['role'] == 'admin') { ?>
<!-- Admin-only Links -->
<li class="nav-item">
<a class="nav-link collapsed" href="Companies.php">
<i class="ri-building-4-line"></i><span>Companies</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Companies Nav -->

<li class="nav-item">
<a class="nav-link active" href="box.php">
<i class="ri-archive-stack-fill"></i><span>Boxes</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Boxes Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="showItems.php">
<i class="ri-shopping-cart-line"></i><span>Items</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Items Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="order.php">
<i class="ri-list-ordered"></i><span>Work Orders</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Work Orders Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="racks.php">
<i class="bi bi-box"></i><span>Racks</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Racks Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="store.php">
<i class="bi bi-shop"></i><span>Store</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Store Nav -->

<?php } else { ?>
<!-- User-only Links -->

<li class="nav-item">
<a class="nav-link active" href="box.php">
<i class="ri-archive-stack-fill"></i><span>Boxes</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Boxes Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="showItems.php">
<i class="ri-shopping-cart-line"></i><span>Items</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Items Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="order.php">
<i class="ri-list-ordered"></i><span>Work Orders</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Work Orders Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="racks.php">
<i class="bi bi-box"></i><span>Racks</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Racks Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="store.php">
<i class="bi bi-shop"></i><span>Store</span><i class="bi bi-chevron ms-auto"></i>
</a>
</li><!-- End Store Nav -->
<?php } ?>


<li class="nav-heading">Pages</li>

<li class="nav-item">
<a class="nav-link collapsed" href="users-profile.php">
<i class="bi bi-person"></i><span>Profile</span>
</a>
</li><!-- End Profile Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="pages-login.php">
<i class="bi bi-box-arrow-right"></i><span>Login</span>
</a>
</li><!-- End Login Nav -->

<li class="nav-item">
<a class="nav-link collapsed" href="logout.php">
<i class="bi bi-box-arrow-left"></i><span>Logout</span>
</a>
</li><!-- End Logout Nav -->

</ul>
</aside>
<!--------------- End sidebar ------------------>


<!-- Button to add new box -->
Expand All @@ -506,7 +506,6 @@

<!-- Main content -->
<main id="main" class="main">

<div class="col-12">
<div class="cardBranch recent-sales overflow-auto">
<div class="card-body">
Expand All @@ -531,9 +530,14 @@
<th scope="col" style="width: 14%;">Company</th>
<th scope="col" style="width: 14%;">Branch</th>
<th scope="col" style="width: 14%;">Created at</th>
<th scope="col" style="width: 10%;">Status</th>
<th scope="col" style="width: 10%;">Action</th>
</tr>
<th scope="col" style="width: 10%;">Status</th>';

// Show "Action" column only for admins
if ($_SESSION['role'] == 'admin') {
echo '<th scope="col" style="width: 10%;">Action</th>';
}

echo '</tr>
</thead>
<tbody style="table-layout: fixed;">';

Expand All @@ -553,7 +557,7 @@
$row3 = $result3->fetch_assoc();
$comp_name = $row3['comp_name'];
}
//show specific company name
// Show specific company name
echo '<td>' . $comp_name . '</td>';

// Get specific branch id
Expand All @@ -564,11 +568,11 @@
$row7 = $result7->fetch_assoc();
$branch_name = $row7['branch_name'];
}
//show specific branch name
// Show specific branch name
echo '<td>' . $branch_name . '</td>';

echo '<td>' . ($row["created_at"]) . '</td>';

echo '<td><i class="';
if ($row["status"] == 'In') {
echo 'fas fa-check-circle text-success';
Expand All @@ -578,16 +582,21 @@
echo 'fas fa-exclamation-triangle text-warning';
}
echo '"></i> ' . $row["status"] . '</td>';
echo '<td>
<div style="display: flex; gap: 10px;">

<a type="button" class="btn btn-danger btn-floating d-flex justify-content-center" style="width:25px; height:28px" data-mdb-ripple-init
onclick="return confirm(\'Are you sure you want to delete this record?\');" href="boxDelete.php?id=' . $row['box_id'] . '"> <i style="width: 20px;" class="fa-solid fa-trash"></i></a>
</div>
</td>';
// Show action buttons only for admins
if ($_SESSION['role'] == 'admin') {
echo '<td>
<div style="display: flex; gap: 10px;">
<a type="button" class="btn btn-danger btn-floating d-flex justify-content-center" style="width:25px; height:28px" data-mdb-ripple-init
onclick="return confirm(\'Are you sure you want to delete this record?\');" href="boxDelete.php?id=' . $row['box_id'] . '"> <i style="width: 20px;" class="fa-solid fa-trash"></i></a>
</div>
</td>';
}

echo '</tr>';
$counter++;
}

echo '</tbody></table>';
} else {
echo '<p>No boxes found.</p>';
Expand All @@ -599,6 +608,7 @@
</main><!-- End #main -->



<script>
function filterCompany(comp_id) {
window.location.href = "box.php?comp_id=" + comp_id;
Expand Down
1 change: 0 additions & 1 deletion config/db.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

// require_once __DIR__ . '/../vendor/autoload.php';

// $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
// $dotenv->Load();
Expand Down
6 changes: 0 additions & 6 deletions createitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,6 @@
<i class="bi bi-box-arrow-left"></i><span>Logout</span>
</a>
</li><!-- End Logout Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-contact.php">
<i class="bi bi-envelope"></i>
<span>Contact</span>
</a>
</li><!-- End Contact Page Nav -->

</ul>
</aside>
Expand Down
7 changes: 1 addition & 6 deletions showItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,7 @@
<i class="bi bi-box-arrow-left"></i><span>Logout</span>
</a>
</li><!-- End Logout Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-contact.php">
<i class="bi bi-envelope"></i>
<span>Contact</span>
</a>
</li><!-- End Contact Page Nav -->


</ul>
</aside>
Expand Down
Loading

0 comments on commit 8f2b905

Please sign in to comment.