Added Documents index. Provides quick to acces view of recently generated Documents. Closes #15
This commit is contained in:
parent
fb94915cde
commit
aae043b04c
|
|
@ -4,9 +4,20 @@ class DocumentsController extends AppController {
|
|||
var $name = 'Documents';
|
||||
var $helpers = array('Html', 'Form', 'Number', 'Decimal');
|
||||
|
||||
|
||||
var $paginate = array(
|
||||
|
||||
'contain' => false,
|
||||
'limit' => 200,
|
||||
'order'=>array('Document.id' => 'desc')
|
||||
|
||||
);
|
||||
|
||||
function index() {
|
||||
$this->Document->recursive = 0;
|
||||
$this->set('documents', $this->paginate());
|
||||
|
||||
$this->set('users', $this->Document->User->getUsersList());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
|
|
@ -281,6 +292,28 @@ class DocumentsController extends AppController {
|
|||
$this->set('products', $document['LineItem']);
|
||||
|
||||
|
||||
//If this is a quote, set the filename
|
||||
//@TODO FIX THIS FOR OTHER DOCTYPES
|
||||
if($document['Quote']['revision'] > 0) {
|
||||
$filename = $enquiry['Enquiry']['title'].'rev'.$document['Quote']['revision'].'.pdf';
|
||||
}
|
||||
else {
|
||||
$filename = $enquiry['Enquiry']['title'].'.pdf';
|
||||
}
|
||||
|
||||
|
||||
$this->set('filename', $filename);
|
||||
$document['Document']['pdf_filename'] = $filename;
|
||||
$document['Document']['pdf_created_at'] = date('Y-m-d H:i:s');
|
||||
$document['Document']['pdf_created_by_user_id'] = $this->getCurrentUserID();
|
||||
if($this->Document->save($document)) {
|
||||
echo "Set pdf_filename attritbute to: ".$filename;
|
||||
}
|
||||
else {
|
||||
echo 'Failed to set pdf_filename to: '.$filename;
|
||||
}
|
||||
|
||||
|
||||
$colWidths = array(
|
||||
'item' => '8%',
|
||||
'qty' => '8%',
|
||||
|
|
@ -306,9 +339,8 @@ class DocumentsController extends AppController {
|
|||
|
||||
$enquiry = $this->Document->Quote->Enquiry->read(null, $document['Quote']['enquiry_id']);
|
||||
$this->set('enquiry', $enquiry);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -13,6 +13,7 @@ class Document extends AppModel {
|
|||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
|
|
@ -155,6 +156,12 @@ class Document extends AppModel {
|
|||
}
|
||||
}
|
||||
|
||||
function isLatestRevision($enquiry) {
|
||||
$number_of_revisions = $this->Document->Quote->findCount('Quote.enquiry_id ='. $enquiry);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -64,5 +64,8 @@ class User extends AppModel {
|
|||
return $this->find('all', array('conditions'=>array('User.principle_id'=>$principleID)));
|
||||
}
|
||||
|
||||
function getUsersList() {
|
||||
return $this->find('list', array('conditions'=>array('User.type'=>'user')));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -8,10 +8,13 @@ echo $paginator->counter(array(
|
|||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('id');?></th>
|
||||
<th><?php echo $paginator->sort('created');?></th>
|
||||
<th>#Pages</th>
|
||||
<th><?php echo $paginator->sort('user_id');?></th>
|
||||
<th>Type</th>
|
||||
<th>#Pages</th>
|
||||
<th>PDF Filename</th>
|
||||
<th>PDF Created</th>
|
||||
<th>PDF Created By</th>
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
@ -23,18 +26,44 @@ foreach ($documents as $document):
|
|||
}
|
||||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
|
||||
<td>
|
||||
<?php echo $document['Document']['id']; ?>
|
||||
<?=$time->nice($document['Document']['created']); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $document['Document']['created']; ?>
|
||||
<?php echo $html->link($document['User']['username'], array('controller' => 'users', 'action' => 'view', $document['User']['id'])); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?=$document['Document']['type'];?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?=$document['Document']['doc_page_count'];?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $html->link($document['User']['username'], array('controller' => 'users', 'action' => 'view', $document['User']['id'])); ?>
|
||||
<?=$html->link($document['Document']['pdf_filename'], '/pdf/'.$document['Document']['pdf_filename']);?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?
|
||||
$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>
|
||||
<?
|
||||
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">
|
||||
|
|
@ -49,3 +78,5 @@ foreach ($documents as $document):
|
|||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||
</div>
|
||||
|
||||
<?php debug($users); ?>
|
||||
|
|
@ -54,6 +54,6 @@ switch($docType) {
|
|||
<?php // debug($currency);?>
|
||||
<?php //debug($docType);?>
|
||||
|
||||
<?php //debug($enquiry);?>
|
||||
<?php debug($enquiry);?>
|
||||
|
||||
<?php debug($document);?>
|
||||
|
|
@ -67,11 +67,18 @@ if (isset($currentuser) == FALSE) {
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li><?php echo $html->link('Documents', '/documents/index'); ?>
|
||||
<ul>
|
||||
<li class="last"><?php echo $html->link('Documents Index', '/documents/index'); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><?php echo $html->link('Jobs', '/jobs/index'); ?>
|
||||
<ul>
|
||||
|
||||
<?
|
||||
if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
|
||||
|
||||
?>
|
||||
<li><?= $html->link('Reports', '/jobs/reports'); ?></li>
|
||||
<? endif; ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue