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 a privatefacility's record.
25
* @author Luke Duncan <lduncan@intrahealth.org>
26
* @copyright Copyright © 2007, 2008 IntraHealth International, Inc.
32
* The page class for displaying the a privatefacility's record.
37
class iHRIS_PageViewPrivateFacility extends I2CE_Page{
38
protected $privatefacility;
41
* Perform the main actions of the page.
43
protected function action() {
45
if (!$this->hasPermission("task(person_can_view)")) {
46
$this->userMessage("You do not have permission to view this person");
49
$this->template->addHeaderLink("view.js");
50
$this->template->appendFileById( "menu_view.html", "li", "navBarUL", true );
51
$this->template->appendFileById( "menu_view_privatefacility.html", "ul", "menuView" );
52
$factory = I2CE_FormFactory::instance();
53
if (!$this->request_exists('id')) {
54
$this->userMessage("Invalid Private Health Unit Requested");
57
if ($this->request_exists('id')) {
58
$id = $this->request('id');
59
if (strpos($id,'|')=== false) {
60
I2CE::raiseError("Deprecated use of id variable");
61
$id = 'privatefacility|' . $id;
64
$id = 'privatefacility|0';
66
$privatefacility = $factory->createContainer( $id);
67
if (!$privatefacility instanceof iHRIS_PrivateFacility) {
71
$this->privatefacility = $privatefacility;
72
$this->privatefacility->populate();
73
$this->privatefacility->getField("supervisor")->setHref("view?id=");
74
$this->template->setForm( $this->privatefacility );
75
$child_forms = $this->privatefacility->getChildForms();
76
foreach($child_forms as $form) {
77
if (!$this->hasPermission("task(person_can_view_child_forms|person_can_view_child_form_{$form})")) {
80
$method = 'action_' . $form;
81
if ($this->_hasMethod($method)) {
82
if (!$this->$method()) {
83
I2CE::raiseError("Could not do action for $form");
91
public function getFacility() {
92
return $this->privatefacility;
95
public function hasChildForm($form, $populate = false) {
97
$this->privatefacility->populateChildren($form);
99
return (array_key_exists($form,$this->privatefacility->children) && is_array($this->privatefacility->children[$form]) && count($this->privatefacility->children[$form]) > 0);
102
public function addChildForms($form, $set_on_node = null , $template = false, $tag = 'div', $append_node = null) {
103
$this->privatefacility->populateChildren($form);
104
return $this->appendChildTemplate($form,$set_on_node,$template,$tag, $append_node );
108
public function addLastChildForm($form, $field, $set_on_node = null, $template = false, $tag = 'div', $append_node = null) {
109
$this->privatefacility->populateLast(array($form=> $field));
110
return $this->appendChildTemplate($form,$set_on_node,$template,$tag, $append_node );
116
public function appendChildTemplate($form,$set_on_node = null, $template = false, $tag = 'div', $appendNode = null) {
117
if (!array_key_exists($form,$this->privatefacility->children) || !is_array($this->privatefacility->children[$form])) {
120
if (!is_string($template)) {
121
$template = 'view_' . $form . '.html';
123
if ($appendNode === null) {
126
if (is_string($appendNode)) {
127
$appendNode = $this->template->getElementById($appendNode);
129
if (! $appendNode instanceof DOMNode) {
130
I2CE::raiseError("Do not know where to add child form $form ");
133
foreach ($this->privatefacility->children[$form] as $child) {
134
I2CE_ModuleFactory::callHooks( 'pre_add_child_form_' . $form,
135
array( 'form' => $child,
136
'page' => $this, 'set_on_node' => $set_on_node,
137
'append_node' => $appendNode ) );
138
$node = $this->template->appendFileByNode($template, $tag, $appendNode );
139
if (!$node instanceof DOMNode) {
140
I2CE::raiseError("Could not find template $template for child form $form of privatefacility");
143
$this->template->setForm($child,$node);
144
if ($set_on_node !== null) {
145
$this->template->setForm($child,$set_on_node);
147
I2CE_ModuleFactory::callHooks( 'post_add_child_form_' . $form,
148
array( 'form' => $child, 'node' => $node,
149
'page' => $this, 'set_on_node' => $set_on_node,
150
'append_node' => $appendNode ) );
162
# c-default-style: "bsd"
163
# indent-tabs-mode: nil