3
* © Copyright 2007, 2008 IntraHealth International, Inc.
5
* This File is part of iHRIS
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.
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.
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/>.
21
* View the history of entries for a particular field.
25
* @author Luke Duncan <lduncan@intrahealth.org>
26
* @copyright Copyright © 2007, 2008 IntraHealth International, Inc.
32
* The page class for displaying the history of a particular field.
37
class iHRIS_PageFieldHistory extends I2CE_Page {
40
* Perform the main actions of the page.
43
protected function action() {
44
$i2ce_config =I2CE::getConfig()->I2CE;
47
$id = $this->get('id');
48
$parent = $this->get('parent');
49
$factory = I2CE_FormFactory::instance();
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 );
56
$this->template->setDisplayData( "return_link", "" );
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";
62
$table_template = "field_history_table.html";
63
$table_template = "field_history_row.html";
65
$this->template->addFile( $table_template );
67
$fields = explode( ",", $this->get('field') );
69
$obj = $factory->createForm( $id );
70
$obj->populateHistory( $fields );
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;
82
foreach( $all_dates as $date => $entries ) {
83
$this->template->appendFileByName( $row_template, "tr", "history_table" );
85
foreach( $fields as $field ) {
86
if ( array_key_exists( $field, $entries ) ) {
88
$this->template->setDisplayData( "date_changed", $entries[$field]->date->displayDate() );
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] ) );
96
$this->template->setDisplayData( $field, "" );
108
# c-default-style: "bsd"
109
# indent-tabs-mode: nil