<?php include('api/read.php'); ?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css" integrity="sha256-zmfNZmXoNWBMemUOo1XUGFfc0ihGGLYdgtJS3KCr/l0=" crossorigin="anonymous" />
<title>CRUD APP</title>
</head>
<body>
<nav class="navbar navbar-dark bg-primary">
<a class="navbar-brand" href="#">CRUD APP</a>
</nav>
<section class="mt-5">
<div class="container">
<div class="row">
<div class="col-lg-10 mx-auto">
<div class="head d-flex align-items-center justify-content-between mb-4">
<div class="title">
<h3 class="mb-0">List Of Users</h3>
</div>
<div class="action">
<button class="btn btn-primary" data-toggle="modal" data-target="#addUser">Add User</button>
</div>
</div>
<table class="table table-striped">
<thead>
<tr class="table-primary">
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Country</th>
<th class="text-center" scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($usersArr as $user) { ?>
<tr>
<th scope="row"><?php echo $user['id'] ?></th>
<td><?php echo $user['user_name'] ?></td>
<td><?php echo $user['user_email'] ?></td>
<td><?php echo $user['country_name'] ?></td>
<td class="text-center">
<a class="btn btn-warning" href="#" data-target="#updateUser" data-toggle="modal"><i class="fas fa-edit"></i></a>
<a class="btn btn-danger" href="#"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</section>
<!-- Start New User Modal -->
<div class="modal fade" id="addUser" tabindex="-1" role="dialog" aria-labelledby="addUser" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add new User</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="api/create.php" method="POST">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="user_name" id="name" placeholder="Name">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" name="user_email" id="email" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<select class="custom-select" name="country_id">
<option selected>Select Country</option>
<option value="1">Poland</option>
<option value="2">Ukraine</option>
<option value="3">Germany</option>
<option value="4">France</option>
</select>
</div>
<button type="submit" class="btn btn-success">Create</button>
</form>
</div>
</div>
</div>
</div>
<!-- End New User Modal -->
<!-- Start New User Modal -->
<div class="modal fade" id="updateUser" tabindex="-1" role="dialog" aria-labelledby="addUser" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add new User</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="api/update.php" method="POST">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Name">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" email="email" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<select class="custom-select" name="country">
<option value="1">Ukraine</option>
<option selected value="2">Poland</option>
<option value="3">Turkey</option>
</select>
</div>
<button type="submit" class="btn btn-success">Create</button>
</form>
</div>
</div>
</div>
</div>
<!-- End New User Modal -->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>