<?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>