HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/company_app/company/dashboard.php
<?php
if (session_status() == PHP_SESSION_NONE) {
    session_start();
 }
require '../include/functions.php'; 
if(!isset($_SESSION["email"]))
{
   header('Location: '.getParentDir().'/index.html');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard | API</title>

    <?php include '../include/head.php'; ?>
   
</head>

<body>
    <div id="wrapper">
        <!-- Navigation -->
        <?php include '../include/sidenav.php'; ?>

        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <h2 class="page-header">Campany List</h2>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">                            
                            <!-- /.panel-heading -->
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>CampanyID</th>
                                                <th>Comapny Name</th>
                                                <th>API End URL</th>
                                                <th>Status</th>
                                                <th>Date</th>
                                                <th>Operation</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            global $conn;
                                            $sql = "SELECT * FROM companies order by id desc";
                                            $result = $conn->query($sql);

                                            if ($result->num_rows > 0) {
                                                // output data of each row
                                                $k=1;
                                                while($row = $result->fetch_assoc()) 
                                                {
                                                    $company_id = $row["company_id"];
                                                    //echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";

                                                    if($k % 2 == 0){
                                                        $even_odd = "even"; 
                                                    }
                                                    else{
                                                        $even_odd = "odd";
                                                    }
                                                     
                                                    ?>
                                                    <tr class="<?php echo $even_odd; ?> gradeX">
                                                        <td><?php echo $k; ?></td>
                                                        <td><?php echo $row["company_id"]; ?></td>
                                                        <td><?php echo $row["company_name"]; ?></td>
                                                        <td><?php echo $row["end_url"]; ?></td>
                                                        <td class="center"><?php if($row["status"] == '1') { echo "Activated"; } else { echo "Deactivated";} ?></td>
                                                        <td class="center"><?php echo $row["created_date"]; ?></td>
                                                        <td class="center">
                                                            <a href="<?php echo getParentDir();?>/company/edit.php?company_id=<?php echo $row["company_id"]; ?>">Edit</a> / 
                                                            <a onclick="cm_delete('<?php echo $company_id; ?>')" data-id="<?php echo $row["company_id"]; ?>" href="#">Delete</a>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                    $k++;
                                                }
                                            } 
                                            else 
                                            {
                                                echo "0 results";
                                            }
                                            $conn->close();
                                            
                                            ?>                                             
                                        </tbody>
                                    </table>
                                </div>
                                <!-- /.table-responsive -->                                 
                            </div>
                            <!-- /.panel-body -->
                        </div>
                        <!-- /.panel -->
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->                 
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->    
    <?php include '../include/footer.php'; ?>
     
    <script>
    function cm_delete(cmid) 
    {        
        if(confirm('Are you sure'))
        {
            var data = {
                company_id: cmid
            };
            $.ajax({
                url: '<?php echo getParentDir();?>/include/functions.php?option=delete_company',
                type: "POST",
                data: data,
            }).done(function(res) {
                
                if (res) // if login successful redirect user to secure.php page.
                {         
                    location.reload();
                } 
                else
                {

                }
            }).fail(function() {
                alert("error");
            }) 
        }         
    };
     
    </script>
</body>
</html>