addressbook/templates/index.html.php

55 lines
2.2 KiB
PHP
Raw Normal View History

2022-10-24 18:40:37 +02:00
<?php include '_header.html.php' ?>
<br>
2022-10-25 15:47:31 +02:00
<h2>Welcome to Address Book</h2>
2022-10-24 18:40:37 +02:00
2022-10-25 15:47:31 +02:00
<?php if(!empty($addresses)): ?>
<form method="POST">
<table id="address_table">
<tr>
<th id="first" onclick="sortBy('first')">First</th>
<th id="last" onclick="sortBy('last')">Last</th>
<th id="street" onclick="sortBy('street')">Street</th>
<th id="zip" onclick="sortBy('zip')">Zip</th>
<th id="city" onclick="sortBy('city')">City</th>
<th id="phone" onclick="sortBy('phone')">Phone</th>
<th colspan="2">&nbsp;</th>
</tr>
<?php foreach ($addresses as $address): ?>
<?php $id = $address->getId(); ?>
<tr id="row_<?= $id ?>">
<td><input type="text" id="first_<?= $id ?>" value="<?= $address->getFirst(); ?>" disabled></td>
<td><input type="text" id="last_<?= $id ?>" value="<?= $address->getLast(); ?>" disabled></td>
<td><input type="text" id="street_<?= $id ?>" value="<?= $address->getStreet(); ?>" disabled></td>
<td><input type="text" id="zip_<?= $id ?>" value="<?= $address->getZip(); ?>" disabled></td>
<td><input type="text" id="city_<?= $id ?>" value="<?= $address->getCity(); ?>" disabled></td>
<td><input type="text" id="phone_<?= $id ?>" value="<?= $address->getPhone(); ?>" disabled></td>
<td>
<input type="button" value="Edit" id="edit_button_<?= $id ?>" onclick="editAddress(<?= $id ?>)">
</td>
<td>
<input type="button" value="Delete" onclick="deleteAddress(<?= $id ?>)">
<input type="hidden" id="owner_<?= $id ?>" value="<?= $id ?>">
</td>
</tr>
<?php endforeach; ?>
<tr style="display:none;">
<td id="first_sort">asc</td>
<td id="last_sort">asc</td>
<td id="street_sort">asc</td>
<td id="zip_sort">asc</td>
<td id="city_sort">asc</td>
<td id="phone_sort">asc</td>
</tr>
</table>
</form>
<?php $addAddress = $router->path('address_add'); ?>
<input type="button" value="Add Address" onclick="addAddress('<?= $addAddress ?>')">
2022-10-25 15:47:31 +02:00
<?php else: ?>
Your addresses will be listed soon
2022-10-25 15:47:31 +02:00
<?php endif; ?>
2022-10-24 20:29:34 +02:00
2022-10-24 18:40:37 +02:00
<?php include '_footer.html.php' ?>