3
* © Copyright 2008 IntraHealth International, Inc.
5
* This File is part of I2CE
7
* I2CE 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
* iHRIS_PageForm_Scheduled_Training_Course
24
* @author Carl Leitner <litlfred@ibiblio.org>
25
* @copyright Copyright © 2008 IntraHealth International, Inc.
26
* This file is part of I2CE. I2CE is free software; you can redistribute it and/or modify it under
27
* the terms of the GNU General Public License as published by the Free Software Foundation; either
28
* version 3 of the License, or (at your option) any later version. I2CE is distributed in the hope
29
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
30
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
31
* received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
37
class iHRIS_PageForm_Scheduled_Training_Course extends I2CE_PageForm{
40
* @var integer The record id number of the object being edited.
46
* @var integer The record id number of the parent of the object being edited.
51
* Create a new instance of this page.
53
* This will call the parent constructor and then setup the base
54
* template pages for the {@link I2CE_Template template}. It also sets up the values
55
* for the member variables.
56
* @param string $title The title for this page.
57
* @param string $defaultHTMLFile The default HTML file for this page.
58
* @param mixed $access The role required to access this page.
59
* @param array $files The list of template files to load for this page.
61
public function __construct( $args,$request_remainder) {
62
parent::__construct( $args,$request_remainder);
65
if ( $this->isPost() ) {
66
if ( $this->post_exists( 'id' ) ) {
67
$this->id = $this->post('id');
69
if ( $this->post_exists( 'parent' ) ) {
70
$this->course_id = $this->post('parent');
73
if ( $this->get_exists( 'id' ) ) {
74
$this->id = $this->get('id');
76
if ( $this->get_exists( 'parent' ) ) {
77
$this->course_id = $this->get('parent');
84
* Create and load data for the objects used for this form.
86
* Create the list object and if this is a form submission load
87
* the data from the form data.
89
protected function loadObjects() {
90
$factory = I2CE_FormFactory::instance();
91
$scheduledCourse = $factory->createForm( "scheduled_training_course", $this->id );
92
$this->setObject( $scheduledCourse);
94
$scheduledCourse->populate();
95
$this->course_id = $scheduledCourse->getParent(true);
97
$parent = $factory->createForm( "training_course", $this->course_id );
99
if ($parent instanceof I2CE_Form) {
101
$this->setObject( $parent , I2CE_PageForm::EDIT_PARENT );
103
parent::loadObjects();
107
* Save the objects to the database.
109
* Save the default object being edited and return to the view page.
112
protected function save() {
114
$this->setRedirect( "view_list?type=training_course&id=" . $this->getParent()->getId() );
117
protected function action() {
118
if ($this->permissionParser->hasTask('can_edit_scheduled_training_course') || $this->permissionParser->hasTask('can_edit_all_database_lists')) {
121
$this->userMessage("You do not have permission to add or edit a scheduled training course",'notice');
122
$this->setRedirect('noaccess');
127
* Display the save or confirm button templates as needed.
128
* @param boolean $save Flag to show the save button.
129
* @param boolean $show_edit (defaults to true)
131
protected function displayControls( $save = false, $show_edit = true ) {
133
$this->template->addFile( "button_save.html" );
134
} elseif ( $this->getPrimary()->getId() > 0 ) {
135
$this->template->addFile( "button_confirm.html" );
137
$node = $this->template->addFile( "button_save_return.html" );
138
$buttonNode = $this->template->getElementById('button_return',$node);
139
if ($buttonNode instanceof DOMElement) {
140
$buttonNode->setAttribute('href','view_list?type=training_course&id=' );
147
public function loadHTMLTemplates() {
148
parent::loadHTMLTemplates();
149
$studentListNode = $this->template->getElementById('list_students');
150
if (!$studentListNode instanceof DOMNode) {
151
$this->template->setDisplayDataImmediate('has_enrolled_students','');
154
$scheduledCourse = $this->getPrimary();
155
if (!$scheduledCourse instanceof iHRIS_Scheduled_Training_Course) {
156
$this->template->setDisplayDataImmediate('has_enrolled_students','');
159
if ($scheduledCourse->getID() < 1) {
160
$this->template->setDisplayDataImmediate('has_enrolled_students','');
163
$personIds = $scheduledCourse->getEnrolledStudents();
164
if (count($personIds) == 0) {
165
$this->template->setDisplayDataImmediate('has_enrolled_students','');
168
$factory = I2CE_FormFactory::instance();
170
foreach ($personIds as $personID) {
174
$person = $factory->createForm('person',$personID);
175
if (!$person instanceof iHRIS_Person) {
179
$personNode = $this->template->appendFileByNode("scheduled_course_list_person.html", 'li',$studentListNode);
180
if (!$personNode instanceof DOMNode) {
184
$this->template->setDisplayDataImmediate('person_surname', $person->surname,$personNode);
185
$this->template->setDisplayDataImmediate('person_firstname',$person->firstname,$personNode);
186
$this->template->setDisplayDataImmediate('person_id','id=' .$personID,$personNode);
189
$this->template->setDisplayDataImmediate('has_enrolled_students','1');
191
$this->template->setDisplayDataImmediate('has_enrolled_students','');
200
# c-default-style: "bsd"
201
# indent-tabs-mode: nil