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) {
|
||||
|
|
@ -212,16 +223,16 @@ class DocumentsController extends AppController {
|
|||
|
||||
if($gst == 1) {
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUB-TOTAL (EXCLUDING GST)',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE (INCLUDING GST)'
|
||||
'subtotal' => 'SUB-TOTAL (EXCLUDING GST)',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE (INCLUDING GST)'
|
||||
);
|
||||
}
|
||||
else {
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUB-TOTAL',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE'
|
||||
'subtotal' => 'SUB-TOTAL',
|
||||
'gst' => 'GST (10%)',
|
||||
'total' => 'TOTAL PAYABLE'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -281,12 +292,34 @@ 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%',
|
||||
'desc' => '60%',
|
||||
'unit' => '12%',
|
||||
'total' => '12%'
|
||||
'item' => '8%',
|
||||
'qty' => '8%',
|
||||
'desc' => '60%',
|
||||
'unit' => '12%',
|
||||
'total' => '12%'
|
||||
|
||||
);
|
||||
|
||||
|
|
@ -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(
|
||||
|
|
@ -89,16 +90,16 @@ class Document extends AppModel {
|
|||
switch($type) {
|
||||
case 'quote':
|
||||
$fullName = 'Quotation';
|
||||
break;
|
||||
break;
|
||||
case 'invoice':
|
||||
$fullName = 'Invoice';
|
||||
break;
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
$fullName = 'Purchase Order';
|
||||
break;
|
||||
break;
|
||||
case 'orderAck':
|
||||
$fullName = 'Order Acknowledgement';
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
}
|
||||
|
|
@ -115,16 +116,16 @@ class Document extends AppModel {
|
|||
case 'quote':
|
||||
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'invoice':
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'orderAck':
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return $fullName;
|
||||
}
|
||||
|
|
@ -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')));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,51 +1,82 @@
|
|||
<div class="documents index">
|
||||
<h2><?php __('Documents');?></h2>
|
||||
<p>
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
|
||||
));
|
||||
?></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 class="actions"><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($documents as $document):
|
||||
$class = null;
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
?>
|
||||
<tr<?php echo $class;?>>
|
||||
<td>
|
||||
<?php echo $document['Document']['id']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $document['Document']['created']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$document['Document']['doc_page_count'];?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $html->link($document['User']['username'], array('controller' => 'users', 'action' => 'view', $document['User']['id'])); ?>
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('action' => 'view', $document['Document']['id'])); ?>
|
||||
</td>
|
||||
<h2><?php __('Documents');?></h2>
|
||||
<p>
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
|
||||
));
|
||||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><?php echo $paginator->sort('created');?></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 endforeach; ?>
|
||||
</table>
|
||||
<?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 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>
|
||||
<?=$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">
|
||||
<?php echo $html->link(__('View', true), array('action' => 'view', $document['Document']['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="paging">
|
||||
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||
| <?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,12 +67,19 @@ 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; ?>
|
||||
<li class="last"><?php echo $html->link('Job List', '/jobs/index'); ?></li>
|
||||
|
|
|
|||
Loading…
Reference in a new issue