Added print view to invoices
This commit is contained in:
parent
683ad89f48
commit
20318e5d6a
|
|
@ -16,6 +16,14 @@ class InvoicesController extends AppController {
|
|||
$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) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid Invoice.', true));
|
||||
|
|
|
|||
|
|
@ -63,11 +63,49 @@ class JobsController extends AppController {
|
|||
|
||||
|
||||
function reports() {
|
||||
$this->Job->recursive = 1;
|
||||
$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'));
|
||||
$this->Job->recursive = 0;
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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'));?>
|
||||
<?=$form->input('date_order_received', array('type'=>'hidden', 'id'=>$job['Job']['id'].'_date_order_received', 'value'=>$job['Job']['date_order_received']));?>
|
||||
</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>
|
||||
<?=$form->input('sale_category', array('options'=>$sale_category_options, 'type'=>'select', 'label'=>false, 'value'=>$job['Job']['sale_category'], 'class'=>'sale_category'));?>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
<td>
|
||||
<?=$job['Job']['job_type'];?></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['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?>
|
||||
<td class="nowrap"><?=$html->link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?></td>
|
||||
<td class="nowrap"><?=$html->link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?>
|
||||
<td><?
|
||||
$poString = '';
|
||||
foreach($job['PurchaseOrder'] as $po) {
|
||||
|
|
|
|||
|
|
@ -79,15 +79,15 @@ echo $paginator->counter(array(
|
|||
<td><button class="editButton">Edit</button></td>
|
||||
<td>
|
||||
<?=$this->element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?></td>
|
||||
<td><?=$job['Job']['job_status'];?></td>
|
||||
<td class="sale_category">
|
||||
<td class=""><?=$job['Job']['job_status'];?></td>
|
||||
<td class="sale_category nowrap">
|
||||
<?=$sale_category_array[$job['Job']['sale_category']];?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$job['Job']['job_type'];?></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['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><?
|
||||
$poString = '';
|
||||
foreach($job['PurchaseOrder'] as $po) {
|
||||
|
|
@ -98,7 +98,7 @@ echo $paginator->counter(array(
|
|||
</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>
|
||||
<td class="nowrap">
|
||||
<?=$job['Job']['customer_order_number'];?>
|
||||
</td>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,65 +1,29 @@
|
|||
<?=$javascript->link('job_reports');?>
|
||||
|
||||
<h2>Book 1 - Reports</h2>
|
||||
|
||||
|
||||
|
||||
<?//debug($jobs); ?>
|
||||
|
||||
<?
|
||||
|
||||
|
||||
$weekList = array();
|
||||
|
||||
|
||||
foreach($jobs as $job) {
|
||||
|
||||
$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;
|
||||
<div id="yearMonths">
|
||||
<?
|
||||
foreach($monthList as $year => $monthArr):
|
||||
?>
|
||||
</td>
|
||||
<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;?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<?endforeach;?>
|
||||
</ul>
|
||||
|
||||
<?endforeach;?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="reports">
|
||||
|
||||
|
||||
</div>
|
||||
|
|
@ -85,6 +85,7 @@
|
|||
<li><?php echo $html->link('Invoices', '/invoices/index'); ?>
|
||||
<ul>
|
||||
<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>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
|
|
@ -1329,8 +1329,53 @@ select.sale_category {
|
|||
width: 300px;
|
||||
}
|
||||
|
||||
select.job_status {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.outer {
|
||||
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;
|
||||
}
|
||||
Loading…
Reference in a new issue