<div class="documents index">
    <h2><?php __('Documents');?></h2>
    <table cellpadding="0" cellspacing="0">
	<tr>
	    <th>Created</th>
	    <th>User</th>
	    <th>Type</th>
	    <th>#Pages</th>
	    <th>PDF Filename</th>
	    <th>PDF Created</th>
	    <th>PDF Created By</th>
	    <th class="actions">Actions</th>
	</tr>
	<?php
	$i = 0;
	foreach ($documents as $document):
	    $class = null;
	    if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	    }
	    ?>
	<tr<?php echo $class;?>>

	    <td>
		    <?=$time->nice($document['Document']['created']); ?>
	    </td>

	    <td>
<?php 
			      $pdf_user_id = $document['Document']['user_id'];
      echo $html->link($users[$pdf_user_id], '/users/view/'.$pdf_user_id);
?>
	    </td>

	    <td>
		    <?=$document['Document']['type'];?>
	    </td>

	    <td>
		    <?=$document['Document']['doc_page_count'];?>
	    </td>

	    <td>
		    <?=$html->link($document['Document']['pdf_filename'], '/pdf/'.$document['Document']['pdf_filename']);?>
	    </td>

	    <td>
		    <?php
		    $pdf_created_at = $document['Document']['pdf_created_at'];
		    if($pdf_created_at != '0000-00-00 00:00:00') {
			    echo $time->nice($document['Document']['pdf_created_at']);
		    }
		    ?>
	    </td>


	    <td>
		    <?php
		    if($document['Document']['pdf_created_by_user_id']) {
			$pdf_user_id = $document['Document']['pdf_created_by_user_id'];
			echo $html->link($users[$pdf_user_id], '/users/view/'.$pdf_user_id);
		    }
		    ?>
	    </td>

	    <td class="actions">
		    <?php echo $html->link(__('View', true), array('action' => 'view', $document['Document']['id'])); ?>
	    </td>
	</tr>
	<?php endforeach; ?>
    </table>
</div>

<?php debug($documents); ?>
