<?php
/**
 * Created by PhpStorm.
 * User: jedi
 * Date: 2/22/19
 * Time: 9:34 PM
 */


?>

<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
    <thead>
    <tr>
        <th>UID</th>
        <th>was</th>
        <th>wann</th>
        <th>wo</th>
        <th>kiste</th>
        <th>foto</th>
        <th></th>
    </tr>
    </thead>
    <tfoot>
    <tr>
        <th>UID</th>
        <th>was</th>
        <th>wann</th>
        <th>wo</th>
        <th>kiste</th>
        <th>foto</th>
        <th></th>
    </tr>
    </tfoot>
    <tbody>
    <?php
    foreach( get_founditems(true) as $item){
        ?>
        <tr>
            <td><?php echo $item["uid"]; ?> </td>
            <td><?php echo $item["was"]; ?></td>
            <td><?php echo $item["wann"]; ?></td>
            <td><?php echo $item["wo"]; ?></td>
            <td><?php echo $item["container"];?></td>
            <td>
                <?php
                    if(isset($item["files"])){
                        ?>
                        <button  class="btn btn-link" data-toggle="modal" data-target="#exampleModal_picture" onclick="show_picture('<?php echo $item["files"][0]["hash"]; ?>')">
                            <img style="height: 48px;" src="/thumb/<?php echo $item["files"][0]["hash"]; ?>">
                        </button>
                        <?php
                    }
                ?>
            </td>
            <!--<td><img style="height: 48px;" src="/upload/<?php echo $item["hash"]; ?>"></td>-->
            <td>
                <div class="btn-group" role="group">
                    <button type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-check-circle"></i></button>
                    <!--<a href="/found_item_edit/<?php echo $item["id"]; ?>/" type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-edit"></i></a>-->
                    <button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#exampleModal"
                            onclick="fill_edit_form(<?php echo $item["id"]; ?>,'<?php echo $item["was"]; ?>','<?php echo $item["wann"]; ?>',
                                    '<?php echo $item["wo"]; ?>','<?php echo $item["hash"]; ?>','<?php echo $item["container"];?>')">
                        <i class="fas fa-fw fa-edit"></i>
                    </button>
                    <button type="button" class="btn btn-outline-danger" onclick="delete_item(<?php echo $item["id"]; ?>)"><i class="fas fa-fw fa-trash-alt"></i></button>
                </div>
            </td>
            <!--td>
                                    <?php
            foreach(explode(",",$item["tags"]) as $tag){
                ?>
                                                <span class="label label-default"><?php echo $tag; ?></span>
                                            <?php
            }
            ?>
                                </td>
                                <td><?php echo $item["id"]; ?></td-->
        </tr>
        <?php
    }
    ?>
    </tbody>
</table>