Basic reports for Proof of Concept done. Will finish tomorrow

This commit is contained in:
Karl Cordes 2011-04-06 18:37:21 +10:00
parent 93ad66701a
commit 683ad89f48
4 changed files with 79 additions and 9 deletions

View file

@ -64,7 +64,7 @@ class JobsController extends AppController {
function reports() {
$this->Job->recursive = 1;
$this->set('jobs', $this->Job->find('all'));
$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'));

View file

@ -52,5 +52,10 @@ class Job extends AppModel {
)
);
function getJobsByWeekNumber() {
}
}
?>

View file

@ -33,20 +33,20 @@ echo $paginator->counter(array(
<tr>
<th class="actions">Actions</th>
<th><?php echo $paginator->sort('Order Received');?></th>
<th><?php echo $paginator->sort('Status');?></th>
<th><?php echo $paginator->sort('Order Received', 'date_order_received');?></th>
<th><?php echo $paginator->sort('Status', 'job_status');?></th>
<th class="sale_category"><?php echo $paginator->sort('Sale Category');?></th>
<th><?php echo $paginator->sort('Job Type');?></th>
<th><?php echo $paginator->sort('Shipment Category');?></th>
<th><?php echo $paginator->sort('Job Number');?></th>
<th><?php echo $paginator->sort('Job Type', 'job_type');?></th>
<th><?php echo $paginator->sort('Shipment Category','shipment_category');?></th>
<th><?php echo $paginator->sort('Job Number','title');?></th>
<th>Enquiry Number</th>
<th>CMC POs</th>
<th>Date Order Placed on Principle</th>
<th><?php echo $paginator->sort('Customer');?></th>
<th><?php echo $paginator->sort('Customer','Customer.name');?></th>
<th>Customer Order No</th>
<th><?php echo $paginator->sort('Supplier Ref');?></th>
<th><?php echo $paginator->sort('Scheduled Ex-Works');?></th>
<th><?php echo $paginator->sort('Date Sent to Customer');?></th>
<th><?php echo $paginator->sort('Scheduled Ex-Works', 'date_scheduled_ex_works');?></th>
<th><?php echo $paginator->sort('Date Sent to Customer', 'date_sent_to_customer');?></th>
<th><?php echo $paginator->sort('Freight Paid By CMC');?></th>
<th><?php echo $paginator->sort('Sale Currency');?></th>
<th><?php echo $paginator->sort('Gross Sales AUD');?></th>

65
views/jobs/reports.ctp Normal file
View file

@ -0,0 +1,65 @@
<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;
?>
</td>
<?endforeach;?>
</tr>
</tbody>
</table>
<?endforeach;?>