~kibsden/ihris-uganda/baylor-train

« back to all changes in this revision

Viewing changes to modules/Trainer/modules/FacilityLicense/lib/iHRIS_Module_FacilityLicense.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 2009 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
* @package UG-Qualify
 
21
* @author Luke Duncan <lduncan@intrahealth.org>
 
22
* @version v4.0.6
 
23
* @since v4.0.6
 
24
* @filesource
 
25
*/
 
26
/**
 
27
* Class iHRIS_Module_FacilityLicense
 
28
*
 
29
* @access public
 
30
*/
 
31
 
 
32
 
 
33
class iHRIS_Module_FacilityLicense extends I2CE_Module {
 
34
 
 
35
    public static function getMethods() {
 
36
        return array(
 
37
            'iHRIS_PageViewPrivateFacility->action_facility_license' => 'action_facility_license'
 
38
            );
 
39
    }
 
40
     /**
 
41
     * Return the array of hooks available in this module.
 
42
     * @return array
 
43
     */
 
44
    public static function getHooks() {
 
45
        return array(
 
46
                'validate_form_facility_license' => 'validate_form_facility_license'
 
47
                );
 
48
    }
 
49
 
 
50
 
 
51
    public function action_facility_license( $page ) {
 
52
        if ( !$page instanceof iHRIS_PageViewPrivateFacility ) {
 
53
            return;
 
54
        }
 
55
        $facility = $page->getFacility();
 
56
        $success = $page->addLastChildForm( 'facility_license', 
 
57
                'end_date', 'siteContent' );
 
58
        $template = $page->getTemplate();
 
59
        if( !$page->hasChildForm( "facility_license" ) ) {
 
60
            $template->appendFileById( "view_privatefacility_license_link.html", "span", "license_links" );
 
61
        } else {
 
62
            $template->appendFileById( "view_privatefacility_renew_link.html", "span", "license_links" );
 
63
        }
 
64
        return $success;
 
65
    }
 
66
       /**
 
67
     * Validate any extra information other than required fields
 
68
     * for licenses.
 
69
     * @param I2CE_Form $form
 
70
     */
 
71
    public function validate_form_facility_license( $form ) {
 
72
        if ( $form->end_date->before( $form->start_date ) ) {
 
73
            $form->getField( "end_date" )->setInvalid( "The license Start date must be after the end date." );
 
74
        }
 
75
        
 
76
    }
 
77
 
 
78
 
 
79
}
 
80
# Local Variables:
 
81
# mode: php
 
82
# c-default-style: "bsd"
 
83
# indent-tabs-mode: nil
 
84
# c-basic-offset: 4
 
85
# End: