~intrahealth+informatics/ihris-plan/1.0.4-release

« back to all changes in this revision

Viewing changes to lib/iHRIS_Projection.php

  • Committer: Luke Duncan
  • Date: 2008-09-05 14:50:25 UTC
  • Revision ID: lduncan@intrahealth.org-20080905145025-w16mkedzeud0i8u2
Added initial projection lines to the model page to show how the projection looked as of the initial year.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
     * @var array The projected population for this projection.
41
41
     */
42
42
    private $__population;
 
43
    /**
 
44
     * @var boolean Flag to determine if the pool projection only includes the initial year's data.
 
45
     */
 
46
    private $__initial_year;
43
47
 
44
48
    /**
45
49
     * Create a new instance of a projection.
59
63
     * Estimate the population for all the years in this projection and return it as an array.
60
64
     * @return array
61
65
     */
62
 
    public function projectPopulation() {
63
 
        if ( count( $this->__population ) == 0 ) {
 
66
    public function projectPopulation( $initial_year = false ) {
 
67
        if ( count( $this->__population ) == 0 || $this->__initial_year !== $initial_year ) {
 
68
            $this->__initial_year = $initial_year;
64
69
            $this->populate();
65
70
            $start_year = $this->start_year->year();
66
71
            $duration = $this->duration;
72
77
            $prev_pop = 0;
73
78
            $prev_rate = 0;
74
79
            for( $year = $start_year; $duration-- >= 0; $year++ ) {
75
 
                if ( array_key_exists( $year, $real_data ) ) {
 
80
                if ( ($initial_year == false || $initial_year = $year) 
 
81
                        && array_key_exists( $year, $real_data ) ) {
76
82
                    $this->__population['pop'][$year] = $real_data[ $year ][ 'population' ];
77
83
                    $this->__population['real'][$year] = true;
78
84
                    $prev_rate = $real_data[ $year ][ 'growth' ];