Added archived list view.
This commit is contained in:
parent
9ebce08617
commit
b44422d14c
|
|
@ -9,9 +9,10 @@ class AttachmentsController extends AppController {
|
|||
|
||||
'limit' => 5000,
|
||||
'order' => array(
|
||||
array('Attachment.principle_id' => 'asc'),
|
||||
array('Principle.short_name' => 'asc'),
|
||||
array('Attachment.name' => 'asc')
|
||||
)
|
||||
),
|
||||
'conditions' => array('Attachment.archived' => 0)
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -29,6 +30,13 @@ class AttachmentsController extends AppController {
|
|||
$this->layout = 'pdf';
|
||||
}
|
||||
|
||||
function archived() {
|
||||
$this->set('archived', $this->Attachment->find('all', array('conditions'=> array('archived' => 1), 'order' => array(
|
||||
array('Principle.short_name' => 'asc'),
|
||||
array('Attachment.name' => 'asc')
|
||||
))));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
|
||||
|
|
@ -57,8 +65,10 @@ class AttachmentsController extends AppController {
|
|||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
//Process editing the PDFs.
|
||||
$attachment = $this->data;
|
||||
$existing = $this->Attachment->find('first', array('conditions'=>array('Attachment.id' => $this->data['Attachment']['id'])));
|
||||
//Process editing the PDFs.
|
||||
if(!empty($this->data['Attachment']['file']['tmp_name'])) {
|
||||
|
||||
if(!empty($existing)) {
|
||||
//Delete old file
|
||||
|
|
@ -70,14 +80,16 @@ class AttachmentsController extends AppController {
|
|||
if(!$attachment) {
|
||||
$this->Session->setFlash('The Attachment could not be saved. The filename exists');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$attachment['Attachment']['file'] = $existing['Attachment']['file'];
|
||||
}
|
||||
if ($this->Attachment->save($attachment)) {
|
||||
$this->Session->setFlash(__('The Attachment has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The Attachment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
53
app/views/attachments/archived.ctp
Normal file
53
app/views/attachments/archived.ctp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th>Principle</th>
|
||||
<th>Created</th>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Size</th>
|
||||
<th class="actions">Actions</th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
|
||||
$last_principle = array();
|
||||
|
||||
foreach ($archived as $attachment):
|
||||
$class = null;
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
<td>
|
||||
<?php
|
||||
if($attachment['Principle']['short_name']) {
|
||||
echo $html->link($attachment['Principle']['short_name'], '/principles/view/'.$attachment['Principle']['id']);
|
||||
}
|
||||
else {
|
||||
echo $html->link($attachment['Principle']['name'], '/principles/view/'.$attachment['Principle']['id']);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $time->nice($attachment['Attachment']['created']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $attachment['Attachment']['name']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $attachment['Attachment']['type']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $number->toReadAbleSize($attachment['Attachment']['size']); ?>
|
||||
</td>
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('action' => 'view', $attachment['Attachment']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $attachment['Attachment']['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
|
@ -1,5 +1,13 @@
|
|||
<div class="attachments index">
|
||||
<h2><?php __('Attachments');?></h2>
|
||||
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('New Attachment', true), array('action' => 'add')); ?></li>
|
||||
<li><?php echo $html->link('View archived', array('action' => 'archived')); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
|
|
@ -8,7 +16,6 @@ echo $paginator->counter(array(
|
|||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('id');?></th>
|
||||
<th><?php echo $paginator->sort('principle_id');?></th>
|
||||
<th><?php echo $paginator->sort('created');?></th>
|
||||
<th><?php echo $paginator->sort('name');?></th>
|
||||
|
|
@ -19,6 +26,9 @@ echo $paginator->counter(array(
|
|||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
|
||||
$last_principle = array();
|
||||
|
||||
foreach ($attachments as $attachment):
|
||||
$class = null;
|
||||
if ($i++ % 2 == 0) {
|
||||
|
|
@ -27,9 +37,6 @@ foreach ($attachments as $attachment):
|
|||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
<td>
|
||||
<?php echo $attachment['Attachment']['id']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if($attachment['Principle']['short_name']) {
|
||||
echo $html->link($attachment['Principle']['short_name'], '/principles/view/'.$attachment['Principle']['id']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue