Fixed unset dates in job report
This commit is contained in:
parent
676c5db9a3
commit
369d5defd4
|
|
@ -122,8 +122,7 @@ class JobsController extends AppController {
|
|||
|
||||
|
||||
function viewReport($year, $month = null) {
|
||||
//$this->layout = 'ajax';
|
||||
|
||||
$this->layout = 'ajax';
|
||||
|
||||
|
||||
if(isset($month) && isset($year)) { //After a Specific Month for a Year
|
||||
|
|
@ -159,10 +158,11 @@ class JobsController extends AppController {
|
|||
}
|
||||
|
||||
elseif(isset($year) && !isset($month)) { //Requested a whole Financial Year Jobs
|
||||
|
||||
|
||||
|
||||
$this->set('year', $year);
|
||||
|
||||
|
||||
|
||||
$lastDayUnix = $this->getLastDayFY($year);
|
||||
$firstDayUnix = $this->getFirstDayFY($year,true);
|
||||
|
||||
|
|
@ -176,20 +176,25 @@ class JobsController extends AppController {
|
|||
$dateString['last'] = date($dateStringFormat, $lastDayUnix);
|
||||
|
||||
|
||||
$jobs = $this->Job->find('all', array('conditions'=>
|
||||
array('Job.date_order_received BETWEEN ? AND ?'=>array($firstDayDate, $lastDayDate))
|
||||
)
|
||||
);
|
||||
$this->set('jobs',$jobs);
|
||||
if($year == 0) { //Jobs with an empty 'date_order_received
|
||||
$jobs = $this->Job->find('all', array('conditions'=>array('Job.date_order_received'=>'0000-00-000')));
|
||||
$jobRangeTitle = "Jobs without Order Received date";
|
||||
}
|
||||
else { //We're looking for Jobs that have an 'date_order_received'
|
||||
|
||||
$jobs = $this->Job->find('all', array('conditions'=>
|
||||
array('Job.date_order_received BETWEEN ? AND ?'=>array($firstDayDate, $lastDayDate))
|
||||
)
|
||||
);
|
||||
|
||||
$lastYear = $year - 1;
|
||||
|
||||
$jobRangeTitle = $lastYear.' - '.$year.' ('.$dateString['first']." to ".$dateString['last'].')';
|
||||
$lastYear = $year - 1;
|
||||
$jobRangeTitle = $lastYear.' - '.$year.' ('.$dateString['first']." to ".$dateString['last'].')';
|
||||
|
||||
}
|
||||
|
||||
$this->set('jobRangeTitle', $jobRangeTitle);
|
||||
|
||||
|
||||
$this->set('jobs',$jobs);
|
||||
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
||||
$this->set('sale_category_options', $this->sale_category_options());
|
||||
$this->set('sale_category_array', $this->sale_category_array());
|
||||
|
|
@ -227,21 +232,21 @@ class JobsController extends AppController {
|
|||
function getTotals($jobs) {
|
||||
|
||||
$fields = array(
|
||||
'company_gross_sales_aud' => 'total',
|
||||
'net_sales_aud' =>'total',
|
||||
'gross_profit_aud' => 'total',
|
||||
'net_export_sales_aud' => 'total',
|
||||
'gross_profit_exports_aud' => 'total',
|
||||
'gp_percent' => 'average',
|
||||
'gross_australian_sales_foreign_currency' => 'total',
|
||||
'net_australian_sales_foreign_currency' => 'total',
|
||||
'gross_profit_value_australian_sales_foreign_currency' => 'total',
|
||||
'gross_export_sales_foreign_currency' => 'total',
|
||||
'net_export_sales_foreign_currency' => 'total',
|
||||
'gross_profit_value_after_discount_exports_foreign_currency' => 'total',
|
||||
'gross_commissions' => 'total',
|
||||
'net_commissions' => 'total'
|
||||
);
|
||||
'company_gross_sales_aud' => 'total',
|
||||
'net_sales_aud' =>'total',
|
||||
'gross_profit_aud' => 'total',
|
||||
'net_export_sales_aud' => 'total',
|
||||
'gross_profit_exports_aud' => 'total',
|
||||
'gp_percent' => 'average',
|
||||
'gross_australian_sales_foreign_currency' => 'total',
|
||||
'net_australian_sales_foreign_currency' => 'total',
|
||||
'gross_profit_value_australian_sales_foreign_currency' => 'total',
|
||||
'gross_export_sales_foreign_currency' => 'total',
|
||||
'net_export_sales_foreign_currency' => 'total',
|
||||
'gross_profit_value_after_discount_exports_foreign_currency' => 'total',
|
||||
'gross_commissions' => 'total',
|
||||
'net_commissions' => 'total'
|
||||
);
|
||||
|
||||
$totals = array();
|
||||
|
||||
|
|
@ -249,7 +254,7 @@ class JobsController extends AppController {
|
|||
$totals[$field] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$jobCount = 0;
|
||||
foreach($jobs as $job) {
|
||||
if($job['Job']['job_status'] == 'JOB CANCELLED' ||
|
||||
|
|
@ -263,7 +268,7 @@ class JobsController extends AppController {
|
|||
$totals[$key] += $job['Job'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$jobCount++;
|
||||
}
|
||||
}
|
||||
|
|
@ -274,7 +279,7 @@ class JobsController extends AppController {
|
|||
$totals[$key] = $avg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $totals;
|
||||
}
|
||||
|
||||
|
|
@ -319,10 +324,10 @@ class JobsController extends AppController {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param <type> $year
|
||||
* @param <type> $prevYear
|
||||
* @return <type>
|
||||
* @return <type>
|
||||
*/
|
||||
function getFirstDayFY($year,$prevYear = false) {
|
||||
if($prevYear == false) {
|
||||
|
|
@ -336,7 +341,7 @@ class JobsController extends AppController {
|
|||
/**
|
||||
*
|
||||
* @param <type> $year
|
||||
* @return <type>
|
||||
* @return <type>
|
||||
*/
|
||||
function getLastDayFY($year) {
|
||||
return mktime(23,59,59,6,30,$year);
|
||||
|
|
@ -344,7 +349,7 @@ class JobsController extends AppController {
|
|||
}
|
||||
|
||||
function getMonthsFY($year) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<?if($year != 1970 && $year != 0):?>
|
||||
<li id="<?=$year?>" class="year"><?=$lastYear?> - <?=$year?> <span class="count">(<?=$count?>)</span></li>
|
||||
<?else:?>
|
||||
<li id="<?=$year?>" class="year">No Date <span class="count">(<?=$count?>)</span></li>
|
||||
<li id="0" class="year">No Date <span class="count">(<?=$count?>)</span></li>
|
||||
<?endif;?>
|
||||
|
||||
<?endforeach;?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue