~kibsden/ihris-uganda/baylor-train

« back to all changes in this revision

Viewing changes to modules/Mentor/lib/iHRIS_PageFormPrivateFacility.php

  • Committer: Dennis Kibiye
  • Date: 2012-08-15 12:39:06 UTC
  • Revision ID: kibsden@gmail.com-20120815123906-ckmfgnpgi8xqiz9o
First Initialisation of In Service Baylor Training System Based on iHRIS Manage

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
* © Copyright 2007 IntraHealth International, Inc.
 
4
 
5
* This File is part of I2CE 
 
6
 
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.
 
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
*  iHRIS_PageFormPrivateFacility
 
22
* @package I2CE
 
23
* @subpackage Core
 
24
* @author Carl Leitner <litlfred@ibiblio.org>
 
25
* @copyright Copyright &copy; 2007 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/>.
 
32
* @version 2.1
 
33
* @access public
 
34
*/
 
35
 
 
36
 
 
37
class iHRIS_PageFormPrivateFacility extends I2CE_PageForm{
 
38
 
 
39
 
 
40
 
 
41
    /**
 
42
     * Create and load data for the objects used for this form.
 
43
     * 
 
44
     * Create the list object and if this is a form submission load
 
45
     * the data from the form data.
 
46
     */
 
47
    protected function loadObjects() {
 
48
        $factory = I2CE_FormFactory::instance();
 
49
        if ($this->isPost()) {
 
50
            $privatefacility = $factory->createContainer('privatefacility');
 
51
            if (!$privatefacility instanceof iHRIS_PrivateFacility) {
 
52
                I2CE::raiseError("Could not create privatefacility form");
 
53
                return;
 
54
            }
 
55
            $privatefacility->load($this->post);
 
56
            $name_ignore = $privatefacility->getField('name_ignore');
 
57
            $ignore_path = array('forms','privatefacility',$privatefacility->getID(),'ignore','name');
 
58
            if ($name_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
 
59
                $name_ignore->setFromPost($this->post($ignore_path));
 
60
            }
 
61
        } else {
 
62
            if ($this->get_exists('id')) {
 
63
                $id = $this->get('id');
 
64
                if (strpos($id,'|')=== false) {
 
65
                    I2CE::raiseError("Depcreated use of id variable");
 
66
                    $id = 'privatefacility|' . $id;
 
67
                }
 
68
            } else {
 
69
                $id = 'privatefacility|0';
 
70
            }
 
71
            $privatefacility = $factory->createContainer($id);
 
72
            if (!$privatefacility instanceof iHRIS_PrivateFacility) {
 
73
                I2CE::raiseError("Could not create valid privatefacility form from id:$id");
 
74
                return;
 
75
            }
 
76
            $privatefacility->populate();
 
77
        }
 
78
        $this->setObject( $privatefacility);
 
79
    }
 
80
 
 
81
    /**
 
82
     * Save the objects to the database.
 
83
     * 
 
84
     * Save the default object being edited and return to the view page.
 
85
     * @global array
 
86
     */
 
87
    protected function save() {
 
88
        parent::save();
 
89
        $this->setRedirect(  "viewprivate?id=" . $this->getPrimary()->getNameId() );
 
90
    }
 
91
 
 
92
    /** 
 
93
     * Display the save or confirm buttons as needed.
 
94
     * 
 
95
     * If the page is a confirmation view then the save / edit button template will be displayed.  
 
96
     * Otherwise the confirm and return buttons will be shown.
 
97
     * @param boolean $save Flag to show the save button. (Defaults to false)
 
98
     * @param boolean $show_edit (defaults to true)
 
99
     * @global array
 
100
     */
 
101
    protected  function displayControls( $save = false, $show_edit = true ) {
 
102
        if ( $save ) {
 
103
            parent::displayControls( $save, $show_edit );
 
104
        }  else {       
 
105
            $this->template->addFile( 'button_facility_confirm_notchild.html' );
 
106
        }               
 
107
    }               
 
108
 
 
109
 
 
110
}
 
111
# Local Variables:
 
112
# mode: php
 
113
# c-default-style: "bsd"
 
114
# indent-tabs-mode: nil
 
115
# c-basic-offset: 4
 
116
# End: