<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * int $document_id ID of the document
 */
?>

<style>

	#wiaas_document_info table {
		margin-top: 25px;
	}

	#wiaas_document_info table > thead {
		background: #f5f5f5;
	}

	#wiaas_document_info table b {
		color: #72777c;
	}

    #tagsdiv-wiaas_doc_type {
        display: none;
    }

    #wiaas_document_new_version {
        max-width: 320px;
        margin: auto;
    }

</style>



<div id="wiaas_document_info">

    <?php echo wp_nonce_field('save_wiaas_doc', 'wiaas_doc_nonce') ?>

    <div id="wiaas_document_new_version">
	    <?php

	    require 'html-document-form.php';

	    ?>
    </div>


	<div class="form-group">
        <table class="widefat">
            <thead>
            <tr>
                <td></td>
                <td><b>Versions</b></td>
                <td></td>
            </tr>
            </thead>
            <tbody id="wiaas_doc_versions">
                <?php
                    $versions = Wiaas_Document::get_document_versions($document_id);

                    foreach ($versions as $index => $version) {
                        ?>
                        <tr>
                            <td><?php esc_html_e('#' . ($index + 1), 'wiaas') ?></td>
                            <td><?php
                                esc_html_e(
                                        wiaas_get_doc_version_filename($version).'.'.wiaas_get_doc_version_extension($version),
                                        'wiaas')
                                ?></td>
                            <td>
                                <a
                                href="<?php echo esc_attr(Wiaas_Document::get_doc_download_link($document_id, $index)) ?>"
                                download>
                                    <span class="dashicons dashicons-download"></span>
                                </a>
                            </td>
                        </tr>
                        <?php
                    }
                ?>
            </tbody>
        </table>
	</div>
</div>
