~ihris+zanzibar/ihris-manage/3.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/*
 * © Copyright 2007, 2008 IntraHealth International, Inc.
 * 
 * This File is part of iHRIS
 * 
 * iHRIS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * @package iHRIS
 * @subpackage Common
 * @author Luke Duncan <lduncan@intrahealth.org>
 * @copyright Copyright &copy; 2007, 2008 IntraHealth International, Inc. 
 * @since v1.0.0
 * @version v2.0.0
 */
/**
 * Object for dealing with districts.
 * 
 * @package iHRIS
 * @subpackage Common
 * @access public
 */
class iHRIS_District extends I2CE_List {

    /**
     * Create a new instance of a district.
     * 
     * @param string $form The name of this form
     * @param integer $id
     */
    public function __construct( $form, $id = 0 ) {
        parent::__construct( $form, $id );
                
        $this->addField('STRING_LINE',"name",  true, true, "country" );
        $this->addField('INT',"country",  true, true );
        $this->fields['country']->setMap( "country", "lookup", "listLocation" );
        $this->addField('INT',"region",  true, true);
        $this->fields['region']->setMap();
        $this->fields['region']->setLink( $this->fields['country'] );
        $this->addField('STRING_LINE',"code");
                
        $this->addField('STRING_LINE',"type", false );
        $this->fields['type']->setValue( $form );
    }

    /**
     * List all districts by region (the linked form for this object).
     * 
     * This will return an array that includes all region codes with all districts that
     * are in that district.
     * @return array
     */
    static public function getOptionsByLink() {
        $factory = I2CE_FormFactory::instance();
        return parent::_getOptionsByLink( $factory->getFormName( get_class() ), self::MAIN_FIELD, "region" );
    }
    
    /**
     * List all districts by country
     * @return array
     */
    static public function getOptionsByCountry() {
        $factory = I2CE_FormFactory::instance();
        return parent::_getOptionsByLink( $factory->getFormName( get_class() ), self::MAIN_FIELD, "country" );
    }
    
}

# Local Variables:
# mode: php
# c-default-style: "bsd"
# indent-tabs-mode: nil
# c-basic-offset: 4
# End: