MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/localapp/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/localapp/admin/view-pendding-reporter.php
<?php
session_start();
$se = $_SESSION["id"];
if (!isset($_SESSION['id'])) {
    header("Location: login.php");
}
include("inc/config.php");
?>

<!DOCTYPE html>
<html lang="en">
<?php require "inc/head.php"; ?>

<body>
    <!-- header-->
    <?php require "inc/header.php"; ?>
    <!-- End Main-content Top bar-->

    <!-- main-content-->
    <div class="wrapper">
        <?php require "inc/sidebar.php"; ?>
        <div id="content">
            <div class="row">
                <div class="col-12 col-sm-12">
                    <div class="row mb-4">
                        <div class="col-12 col-md-12">
                            <div class="card redial-border-light redial-shadow mb-4">
                                <div class="card-body">
                                    <h6 class="header-title pl-3 redial-relative">Data Table</h6>
                                    <!-- <table id="example" class="table table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Reporter Name</th>
                                                <th>Email</th>
                                                <th>Phone</th>
                                                <th>Password</th>
                                            
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                        
                                            $query = "SELECT vendor.id, vendor.name, vendor.username, vendor.phone, vendor.password, 
                                                            COUNT(DISTINCT news.id) AS news_count, 
                                                            COUNT(DISTINCT follow.user_id) AS follower_count 
                                                    FROM vendor 
                                                    LEFT JOIN news ON vendor.id = news.reporter_id 
                                                    LEFT JOIN follow ON vendor.id = follow.reporter_id 
                                                    GROUP BY vendor.id";

                                            $query_run = mysqli_query($conn, $query);

                                            if (mysqli_num_rows($query_run) > 0) {
                                                foreach ($query_run as $row) {
                                            ?>
                                                    <tr>
                                                        <td><?php echo $row['id']; ?></td>
                                                        <td><?php echo $row['name']; ?></td>
                                                        <td><?php echo $row['username']; ?></td>
                                                        <td><?php echo $row['phone']; ?></td>
                                                        <td><?php echo $row['password']; ?></td>
                                                    
                                                        <td>
                                                            <div class='btn-group mb-2'>
                                                            <a href="aprove-reporter.php?id=<?php echo $row['id']; ?>" class="btn btn-info">
                                                                    <i class='fa fa-check'></i>
                                                                </a>
                                                                &nbsp;&nbsp;

                                                                <a href="update-reporter.php?id=<?php echo $row['id']; ?>" class="btn btn-success">
                                                                    <i class='fa fa-pencil'></i>
                                                                </a>
                                                                &nbsp;&nbsp;

                                                                <form action="add_reporter.php" method="post" style="display:inline-block;">
                                                                    <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
                                                                    <button type="submit" name="delete_reporter" class="btn btn-danger" data-bs-toggle="tooltip" title="Delete Reporter">
                                                                        <i class='fa fa-trash'></i>
                                                                    </button>
                                                                </form>
                                                            </div>
                                                        </td>
                                                    </tr>
                                            <?php }
                                            } ?>
                                        </tbody>
                                    </table> -->

                                    <table id="example" class="table table-bordered" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>#</th>
            <th>Reporter Name</th>
            <th>Email</th>
            <th>Phone</th>
            <th>Password</th>
            <th>Status</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $query = "SELECT vendor.id, vendor.name, vendor.username, vendor.phone, vendor.password, vendor.status
                  FROM vendor
                  WHERE vendor.status = 'Pending'";

        $query_run = mysqli_query($conn, $query);
        $counter = 1; // Initialize counter

        if (mysqli_num_rows($query_run) > 0) {
            foreach ($query_run as $row) {
        ?>
                <tr id="row_<?php echo $row['id']; ?>">
                    <td><?php echo $counter++; ?></td> <!-- Display sequential numbering -->
                    <td><?php echo $row['name']; ?></td>
                    <td><?php echo $row['username']; ?></td>
                    <td><?php echo $row['phone']; ?></td>
                    <td><?php echo $row['password']; ?></td>
                    <td id="status_<?php echo $row['id']; ?>"><?php echo $row['status']; ?></td>
                    <td>
                        <div class='btn-group mb-2'>
                            <button class="btn btn-info approve-btn" data-id="<?php echo $row['id']; ?>" id="approve_<?php echo $row['id']; ?>">
                                <i class='fa fa-check'></i> 
                            </button>
                            &nbsp;&nbsp;
                            <a href="update-reporter.php?id=<?php echo $row['id']; ?>" class="btn btn-success">
                                <i class='fa fa-pencil'></i>
                            </a>
                            &nbsp;&nbsp;
                            <form action="delete_reporter.php" method="post" style="display:inline-block;">
                                <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
                                <button type="submit" name="delete_reporter" class="btn btn-danger">
                                    <i class='fa fa-trash'></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
        <?php }
        } else {
            echo "<tr><td colspan='7' class='text-center'>No pending reporters found</td></tr>";
        }
        ?>
    </tbody>
</table>




                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End main-content-->

    <!-- Top To Bottom-->
    <a href="#" class="scrollup text-center redial-bg-primary redial-rounded-circle-50">
        <h4 class="text-white mb-0"><i class="icofont icofont-long-arrow-up"></i></h4>
    </a>
    <!-- End Top To Bottom-->

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
   $(document).ready(function () {
    $(document).on("click", ".approve-btn", function () {
        var reporterId = $(this).data("id");
        var button = $(this);
        
        $.ajax({
            url: "approve_reporter.php",
            type: "POST",
            data: { id: reporterId },
            success: function (response) {
                console.log(response); // Debugging: check what response is received
                if (response.trim() === "success") {
                    $("#status_" + reporterId).text("Approved"); // Update status in UI
                    $("#row_" + reporterId).fadeOut("slow"); // Remove row after approval
                } else {
                    alert("Failed to approve reporter. Try again!");
                }
            },
            error: function (xhr, status, error) {
                console.error("AJAX Error:", error);
                alert("An error occurred. Check console for details.");
            }
        });
    });
});

    </script>
    <!-- jQuery -->
    <script src="dist/js/plugins.min.js"></script>
    <script src="dist/js/common.js"></script>
</body>
</html>

MMCT - 2023