D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
inventory.tapaslights.com
/
Filename :
index.php
back
Copy
<?php include 'config.php'; if (!isset($_SESSION['admin_name'])) { echo '<script>window.location.href = "login.php";</script>'; exit; } $sql = "SELECT material_name, transaction_type, quantity, price_per_unit, total_price, created_at FROM material_transactions ORDER BY created_at DESC"; $result = mysqli_query($conn, $sql); ?> <!DOCTYPE html> <html lang="en" data-layout="vertical" data-topbar="light" data-sidebar="light" data-sidebar-size="lg" data-sidebar-image="none"> <head> <?php include 'style.php' ?> </head> <body> <!-- Main Wrapper --> <div class="main-wrapper"> <!-- Header --> <?php include 'header.php' ?> <!-- /Header --> <!-- Sidebar --> <?php include 'sidebar.php' ?> <!-- /Sidebar --> <!-- Page Wrapper --> <div class="page-wrapper"> <div class="content container-fluid"> <?php // Project Count $projectCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as count FROM projects"))['count']; // Material Count (total unique materials) $materialCount = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as total FROM materials"))['total'] ?? 0; // Today's Spending (Cash Out) $today = date('Y-m-d'); $cashOutToday = mysqli_fetch_assoc(mysqli_query($conn, " SELECT SUM(total_price) as total FROM material_transactions WHERE transaction_type = 'out' AND DATE(created_at) = '$today' "))['total'] ?? 0; ?> <div class="row"> <!-- Project Count --> <div class="col-xl-4 col-sm-6 col-12"> <div class="card"> <div class="card-body"> <div class="dash-widget-header"> <span class="dash-widget-icon bg-primary"> <i class="fa-solid fa-diagram-project"></i> </span> <div class="dash-count"> <div class="dash-title">Projects</div> <div class="dash-counts"> <p><?= $projectCount ?></p> </div> </div> </div> </div> </div> </div> <!-- Material Count (Unique Materials) --> <div class="col-xl-4 col-sm-6 col-12"> <div class="card"> <div class="card-body"> <div class="dash-widget-header"> <span class="dash-widget-icon bg-success"> <i class="fa-solid fa-cogs"></i> </span> <div class="dash-count"> <div class="dash-title">Materials</div> <div class="dash-counts"> <p><?= $materialCount ?></p> </div> </div> </div> </div> </div> </div> <!-- Today's Spending --> <!-- Today's Spending --> <div class="col-xl-4 col-sm-6 col-12"> <div class="card"> <div class="card-body"> <div class="dash-widget-header"> <span class="dash-widget-icon bg-danger"> <i class="fa-solid fa-indian-rupee-sign"></i> </span> <div class="dash-count"> <div class="dash-title">Today's Spending</div> <div class="dash-counts"> <?php $today = date('Y-m-d'); // Try with different transaction_type values if needed $cashOutQuery = "SELECT SUM(total_price) as total FROM material_transactions WHERE (transaction_type = 'out' OR transaction_type = 'deduct') AND DATE(created_at) = '$today'"; $cashOutResult = mysqli_query($conn, $cashOutQuery); $cashOutToday = mysqli_fetch_assoc($cashOutResult)['total'] ?? 0; ?> <p class="text-danger">₹<?= number_format((float)$cashOutToday, 2) ?></p> </div> </div> </div> </div> </div> </div> </div> <!-- data table --> <div class="content container-fluid"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-header card-buttons"> <h4 class="card-title">Business Book</h4> </div> <div class="card-body"> <div class="table-responsive"> <table class="datatable table table-striped"> <thead> <tr> <th>Material Name</th> <th>Type</th> <th>Quantity</th> <th>Price per Unit (₹)</th> <th>Total Price (₹)</th> <th>Date</th> </tr> </thead> <tbody> <?php if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . htmlspecialchars($row['material_name']) . "</td>"; echo "<td>" . strtoupper(htmlspecialchars($row['transaction_type'])) . "</td>"; echo "<td>" . htmlspecialchars($row['quantity']) . "</td>"; echo "<td>₹" . number_format($row['price_per_unit'], 2) . "</td>"; echo "<td class='text-danger'>₹" . number_format($row['total_price'], 2) . "</td>"; echo "<td>" . date('Y-m-d', strtotime($row['created_at'])) . "</td>"; echo "</tr>"; } } else { echo "<tr><td colspan='6'>No transactions found.</td></tr>"; } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> </div> </div> <!-- /Page Wrapper --> </div> <!-- /Main Wrapper --> <?php include 'footer.php' ?> </body> </html>