~oh-dev/openhealth/phit-tools

« back to all changes in this revision

Viewing changes to ihris-suite/lib/common/lib/iHRIS_PageFieldHistory.php

  • Committer: litlfred at ibiblio
  • Date: 2009-10-26 13:55:16 UTC
  • Revision ID: litlfred@ibiblio.org-20091026135516-7er0260tad01febt
ihris suite updated to 4.0.1 pre-release...
follows that did not get added on the last attempt did this time... the problem is that bzr does not like to include branches in a sub-directory even if you add them in which 
  is how ihris-suite/lib/* was structed.  so i had to move ihris-suite/lib/*/.bzr to ihris-suite/lib/*/.bzr_dir to trick it
the site will now succesfully install.  have not attempted change the root drive letter yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * © Copyright 2007, 2008 IntraHealth International, Inc.
 
4
 * 
 
5
 * This File is part of iHRIS
 
6
 * 
 
7
 * iHRIS is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 * 
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 * 
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
/**
 
21
 * View the history of entries for a particular field.
 
22
 * @package iHRIS
 
23
 * @subpackage Common
 
24
 * @access public
 
25
 * @author Luke Duncan <lduncan@intrahealth.org>
 
26
 * @copyright Copyright &copy; 2007, 2008 IntraHealth International, Inc. 
 
27
 * @since v2.0.0
 
28
 * @version v2.0.0
 
29
 */
 
30
 
 
31
/**
 
32
 * The page class for displaying the history of a particular field.
 
33
 * @package iHRIS
 
34
 * @subpackage Common
 
35
 * @access public
 
36
 */
 
37
class iHRIS_PageFieldHistory extends I2CE_Page {
 
38
        
 
39
    /**
 
40
     * Perform the main actions of the page.
 
41
     * @global array
 
42
     */
 
43
    protected function action() {
 
44
        $i2ce_config =I2CE::getConfig()->I2CE;
 
45
        parent::action();
 
46
                
 
47
        $id = $this->get('id');
 
48
        $parent = $this->get('parent');
 
49
        $factory = I2CE_FormFactory::instance();
 
50
                
 
51
        if ( $this->get('type') == "person" ) {
 
52
            $this->template->setForm( $factory->createForm( ($parent != '0|0' ? $parent : $id ) ) );
 
53
            $this->template->setDisplayData( "return_link",  array('href'=>'view','id'=> ($parent != '0|0' ? $parent : $id ) ));
 
54
            $this->template->appendFileById( "menu_view_link.html", "li", "navBarUL", true );
 
55
        } else {
 
56
            $this->template->setDisplayData( "return_link", "" );
 
57
        }
 
58
        if ( $this->get_exists( 'template' ) ) {
 
59
            $table_template = "field_history_" . $this->get('template') . ".html";
 
60
            $row_template = "field_history_row_" . $this->get('template') . ".html";
 
61
        } else {
 
62
            $table_template = "field_history_table.html";
 
63
            $table_template = "field_history_row.html";
 
64
        }
 
65
        $this->template->addFile( $table_template );
 
66
                
 
67
        $fields = explode( ",", $this->get('field') );
 
68
                
 
69
        $obj = $factory->createForm( $id );
 
70
        $obj->populateHistory( $fields );
 
71
 
 
72
        $all_dates = array();
 
73
        foreach( $fields as $field ) {
 
74
            while ( $obj->getField($field)->hasNextHistory() ) {
 
75
                $entry = $obj->getField($field)->nextHistory();
 
76
                $all_dates[ $entry->date->dbFormat() ][$field] = $entry;
 
77
            }
 
78
        }
 
79
        ksort( $all_dates );
 
80
        
 
81
        $previous = array();
 
82
        foreach( $all_dates as $date => $entries ) {
 
83
            $this->template->appendFileByName( $row_template, "tr", "history_table" );
 
84
            $first = true;
 
85
            foreach( $fields as $field ) {
 
86
                if ( array_key_exists( $field, $entries ) ) {
 
87
                    if ( $first ) {
 
88
                        $this->template->setDisplayData( "date_changed", $entries[$field]->date->displayDate() );
 
89
                        $first = false;
 
90
                    }
 
91
                    $this->template->setDisplayData( $field, $obj->getField($field)->getDisplayValue( $entries[$field] ) );
 
92
                    $previous[$field] = $entries[$field];
 
93
                } elseif ( array_key_exists( $field, $previous ) ) {
 
94
                    $this->template->setDisplayData( $field, $obj->getField($field)->getDisplayValue( $previous[$field] ) );
 
95
                } else {
 
96
                    $this->template->setDisplayData( $field, "" );
 
97
                }
 
98
            }
 
99
        }
 
100
 
 
101
    }
 
102
        
 
103
}
 
104
 
 
105
 
 
106
# Local Variables:
 
107
# mode: php
 
108
# c-default-style: "bsd"
 
109
# indent-tabs-mode: nil
 
110
# c-basic-offset: 4
 
111
# End: