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

/**
 * int $id  ID of the attached document
 */

$doc_info = Wiaas_Document::get_doc_info($id);
$type = isset($doc_info['type']) && is_array($doc_info['type']) ? $doc_info['type']['name'] : ' - ';

$visible = Wiaas_Document::is_doc_visible($id);

?>

<tr id="wiaas_attached_document_<?php echo esc_attr($id); ?>">
    <td width="1%">
        <?php
        if ($visible) {
            echo '<span class="dashicons dashicons-visibility"></span>';
        } else {
            echo '<span class="dashicons dashicons-hidden"></span>';
        }
        ?>
    </td>
	<td>
		<div>
			<input type="hidden" name="wiaas_attached_documents[]" value="<?php echo esc_attr($id); ?>" />
			<b>
				<?php esc_html_e($doc_info['name'], 'wiaas'); ?>
            </b>
		</div>
	</td>
    <td>
        <span>
            <?php esc_html_e($type, 'wiaas'); ?>
        </span>
    </td>
    <td width="1%"><a href="<?php echo esc_attr($doc_info['url']) ?>" download>
            <span class="dashicons dashicons-download"></span>
        </a>
    </td>
	<td width="1%">
		<button
			data-id="<?php echo esc_attr($id); ?>"
			class="button wiaas-remove-attached-document">
            <small><?php esc_html_e('Remove', 'wiaas'); ?></small>
        </button>
	</td>
</tr>
