<?php require('classes/main.php'); ?>
<?php require('classes/loginCheck.php'); ?>
<!DOCTYPE html>
<html>
<?php require('common/head.php'); ?>

<body>
    <div class="container">
        <?php
    $idsubject = isset($_GET['idsubject']) ? (int) $_GET['idsubject'] : 0;
    if($main->checkUserSubject($_SESSION['iduser'], $idsubject)) { 
        $subjects = $main->subjects($idsubject); ?>
        <h1>Documentos <em><?php echo $subjects[$idsubject]['subject']; ?></em></h1>
        <table id="datatable" class="stripe" style="width:100%">
            <thead>
                <tr>
                    <th>Id.</th>
                    <th>Documento</th>
                    <th>Fecha de registro</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach($main->subjectsDocuments($idsubject) as $idsubjectdocument => $document) { ?>
                <tr>
                    <td><?php echo $idsubjectdocument; ?></td>
                    <td><a href="<?php echo $document['path'] != '' ? $document['path'] : 'javascript:void(0);' ?>"
                            target="_blank"><?php echo $document['title']; ?></a><br /><?php echo $document['description']; ?>
                    </td>
                    <td><?php echo $document['fname'] . ' ' . $document['lname']; ?><br /><?php echo $document['created']; ?>
                    </td>
                    </td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
        <?php } ?>
        <?php require('common/footer.php'); ?>
</body>

</html>