Added print view to invoices

This commit is contained in:
Karl Cordes 2011-04-07 12:26:26 +10:00
parent 683ad89f48
commit 20318e5d6a
8 changed files with 134 additions and 78 deletions

View file

@ -16,6 +16,14 @@ class InvoicesController extends AppController {
$this->set('invoices', $this->paginate()); $this->set('invoices', $this->paginate());
} }
function printView() {
$this->layout = 'minimal';
$this->Invoice->recursive = 0;
$this->set('invoices', $this->Invoice->find('all'));
}
function view($id = null) { function view($id = null) {
if (!$id) { if (!$id) {
$this->Session->setFlash(__('Invalid Invoice.', true)); $this->Session->setFlash(__('Invalid Invoice.', true));

View file

@ -57,32 +57,70 @@ class JobsController extends AppController {
$this->set('shipment_options', $this->shipment_options()); $this->set('shipment_options', $this->shipment_options());
$this->set('freight_paid_by_options',$this->freight_paid_options()); $this->set('freight_paid_by_options',$this->freight_paid_options());
$this->set('gst_options', $this->gst_options()); $this->set('gst_options', $this->gst_options());
} }
function reports() { function reports() {
$this->Job->recursive = 1; $this->Job->recursive = 0;
$this->set('jobs', $this->Job->find('all', array('order'=>array('Job.date_order_received'=>'asc'))));
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
$this->set('currencies', $this->Job->Currency->find('list'));
$jobs = $this->Job->find('all', array('fields'=>array('Job.date_order_received'), 'order'=>array('Job.date_order_received'=>'asc')));
$monthList = $this->getYearMonths($jobs);
$this->set('monthList', $monthList);
/* $this->set('jobs', $jobs);
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
$this->set('currencies', $this->Job->Currency->find('list'));*/
}
function viewReport($year, $month) {
$this->layout = 'ajax';
$this->set('year', $year);
$this->set('month', $month);
}
/**
* Build an array of Years/Months with Jobs.
*
* Currently used in reports.ctp to build the Navigation list.
*
* @param Array $jobs
* @return Array
*/
function getYearMonths($jobs) {
$weekList = array();
foreach($jobs as $job) {
$time = strtotime($job['Job']['date_order_received']);
$year = date('Y', $time); //ISO-8601 year number
$month = date('F', $time);
$monthList[$year][$month][] = $job;
}
krsort($monthList);
return $monthList;
} }
function job_status_options() { function job_status_options() {
$options = array('ORDER RECEIVED FROM CUSTOMER', $options = array('ORDER RECEIVED FROM CUSTOMER',
'ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY', 'ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY',
'GOODS SHIPPED TO CUSTOMER - CMC WAITING ON PAYMENT', 'GOODS SHIPPED TO CUSTOMER - CMC WAITING ON PAYMENT',
'WAITING ON PAYMENT AND ANOTHER DELIVERY', 'WAITING ON PAYMENT AND ANOTHER DELIVERY',
'GOODS DELIVERED TO CUSTOMER - CMC PAID IN FULL', 'GOODS DELIVERED TO CUSTOMER - CMC PAID IN FULL',
'PAID IN FULL WAITING ON DELIVERY', 'PAID IN FULL WAITING ON DELIVERY',
'JOB CANCELLED', 'JOB CANCELLED',
'JOB ON HOLD', 'JOB ON HOLD',
'CUSTOMER TO PAY 100% WITH ORDER'); 'CUSTOMER TO PAY 100% WITH ORDER');
$options = $this->buildEnumOpts($options); $options = $this->buildEnumOpts($options);
return $options; return $options;
} }

View file

@ -72,7 +72,7 @@ else {
<td><?=$form->input('date_order_received_display', array('value'=>$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received'])), 'label'=>false, 'id'=>$job['Job']['id'].'_date_order_received_display'));?> <td><?=$form->input('date_order_received_display', array('value'=>$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received'])), 'label'=>false, 'id'=>$job['Job']['id'].'_date_order_received_display'));?>
<?=$form->input('date_order_received', array('type'=>'hidden', 'id'=>$job['Job']['id'].'_date_order_received', 'value'=>$job['Job']['date_order_received']));?> <?=$form->input('date_order_received', array('type'=>'hidden', 'id'=>$job['Job']['id'].'_date_order_received', 'value'=>$job['Job']['date_order_received']));?>
</td> </td>
<td><?=$form->input('job_status', array('type'=>'select', 'options'=>$job_status_options, 'value'=>$job['Job']['job_status'], 'label'=>false));?></td> <td><?=$form->input('job_status', array('type'=>'select', 'options'=>$job_status_options, 'value'=>$job['Job']['job_status'], 'label'=>false, 'class'=>'job_status'));?></td>
<td> <td>
<?=$form->input('sale_category', array('options'=>$sale_category_options, 'type'=>'select', 'label'=>false, 'value'=>$job['Job']['sale_category'], 'class'=>'sale_category'));?> <?=$form->input('sale_category', array('options'=>$sale_category_options, 'type'=>'select', 'label'=>false, 'value'=>$job['Job']['sale_category'], 'class'=>'sale_category'));?>
</td> </td>

View file

@ -8,8 +8,8 @@
<td> <td>
<?=$job['Job']['job_type'];?></td> <?=$job['Job']['job_type'];?></td>
<td><?=$job['Job']['shipment_category'];?></td> <td><?=$job['Job']['shipment_category'];?></td>
<td><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></td> <td class="nowrap"><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></td>
<td><?=$html->link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?> <td class="nowrap"><?=$html->link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?>
<td><? <td><?
$poString = ''; $poString = '';
foreach($job['PurchaseOrder'] as $po) { foreach($job['PurchaseOrder'] as $po) {

View file

@ -79,15 +79,15 @@ echo $paginator->counter(array(
<td><button class="editButton">Edit</button></td> <td><button class="editButton">Edit</button></td>
<td> <td>
<?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?></td> <?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?></td>
<td><?=$job['Job']['job_status'];?></td> <td class=""><?=$job['Job']['job_status'];?></td>
<td class="sale_category"> <td class="sale_category nowrap">
<?=$sale_category_array[$job['Job']['sale_category']];?> <?=$sale_category_array[$job['Job']['sale_category']];?>
</td> </td>
<td> <td>
<?=$job['Job']['job_type'];?></td> <?=$job['Job']['job_type'];?></td>
<td><?=$job['Job']['shipment_category'];?></td> <td><?=$job['Job']['shipment_category'];?></td>
<td><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></td> <td><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></td>
<td><?=$html->link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?> <td class="nowrap"><?=$html->link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?>
<td><? <td><?
$poString = ''; $poString = '';
foreach($job['PurchaseOrder'] as $po) { foreach($job['PurchaseOrder'] as $po) {
@ -98,7 +98,7 @@ echo $paginator->counter(array(
</td> </td>
<td><?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_placed_on_principle']));?></td> <td><?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_placed_on_principle']));?></td>
<td><?=$html->link($job['Customer']['name'], array('controller'=>'customers','action'=>'view', $job['Customer']['id']));?></td> <td><?=$html->link($job['Customer']['name'], array('controller'=>'customers','action'=>'view', $job['Customer']['id']));?></td>
<td> <td class="nowrap">
<?=$job['Job']['customer_order_number'];?> <?=$job['Job']['customer_order_number'];?>
</td> </td>

View file

@ -1,65 +1,29 @@
<?=$javascript->link('job_reports');?>
<h2>Book 1 - Reports</h2> <h2>Book 1 - Reports</h2>
<div id="yearMonths">
<?
foreach($monthList as $year => $monthArr):
?>
<ul class="yearList">
<li><span class="year"><?=$year?></span>
<ul class="monthList" id="<?=$year?>">
<?foreach($monthArr as $month => $job):?>
<li><span class="month"><?=$month;?></span></li>
<?endforeach;?>
</ul>
</li>
</ul>
<?//debug($jobs); ?> <?endforeach;?>
<? </div>
$weekList = array(); <div id="reports">
foreach($jobs as $job) { </div>
$time = strtotime($job['Job']['date_order_received']);
$year = date('Y', $time); //ISO-8601 year number
$weekNo = date('W', $time);
$weekList[$year][$weekNo][] = $job;
/*if(isset($weekList[$year][$weekNo])) {
$weekList[$year][$weekNo]++;
}
else {
$weekList[$year][$weekNo] = 0;
}*/
}
//echo debug($weekList);
foreach($weekList as $year => $weekNos):
?>
<h2><?=$year?></h2>
<table>
<thead>
<tr>
<? foreach ($weekNos as $week => $jobArr): ?>
<th>Week <?=$week?></th>
<?endforeach;?>
</tr>
</thead>
<tbody>
<tr>
<? foreach ($weekNos as $week => $jobArr): ?>
<td>
<? $totalSales = 0;
foreach($jobArr as $job) {
$totalSales += $job['Job']['company_gross_sales_aud'];
}
echo $totalSales;
?>
</td>
<?endforeach;?>
</tr>
</tbody>
</table>
<?endforeach;?>

View file

@ -85,6 +85,7 @@
<li><?php echo $html->link('Invoices', '/invoices/index'); ?> <li><?php echo $html->link('Invoices', '/invoices/index'); ?>
<ul> <ul>
<li class="last"><?php echo $html->link('Invoices Index', '/invoices/index'); ?></li> <li class="last"><?php echo $html->link('Invoices Index', '/invoices/index'); ?></li>
<li class="last"><?php echo $html->link('Print View', '/invoices/printView'); ?></li>
</ul> </ul>
</li> </li>

View file

@ -1329,8 +1329,53 @@ select.sale_category {
width: 300px; width: 300px;
} }
select.job_status {
width: 300px;
}
.outer { .outer {
height: 650px; height: 650px;
}
.nowrap {
margin: 0;
padding: 0;
white-space: nowrap;
}
/* CSS for the Job Reporting */
#yearMonths {
width: 10em;
}
ul.yearList {
list-style: none;
padding-bottom: 1em;
}
ul.monthList {
list-style: none;
padding-left: 0.5em;
}
ul.yearList li.year {
margin: 1em;
font-size: 200%;
cursor: pointer;
}
ul.monthList li {
margin-left:1em;
margin-top:0.5em;
}
span.month {
cursor: pointer;
}
span.year {
cursor: pointer;
} }