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/>.
23
* @author Luke Duncan <lduncan@intrahealth.org>
24
* @copyright Copyright © 2007, 2008 IntraHealth International, Inc.
29
* Object for dealing with positions assigned to people.
35
class iHRIS_PersonPosition extends I2CE_Form {
38
* Create a new instance of a person position.
40
* @param string $form The name of this form
43
public function __construct( $form, $id = 0 ) {
44
parent::__construct( $form, $id );
45
$this->start_date = I2CE_Date::now();
46
$this->end_date = I2CE_Date::blank();
51
* Return the record id and the parent id for the person position record
52
* for the given position.
53
* @param integer $position
56
static public function getIds( $position ) {
57
$pos_det = I2CE_FormField::getFormFieldIdAndType( "person_position", "position" );
58
$end_det = I2CE_FormField::getFormFieldIdAndType( "person_position", "end_date" );
59
if ( !$pos_det || !$end_det ) return array();
61
$db = MDB2::singleton();
62
if ( !I2CE::pearError( $db, "Error getting database connection: " ) ) {
64
$row = $db->getRow( "SELECT e1.record FROM last_entry e1 JOIN last_entry e2 ON e1.record = e2.record WHERE e1.form_field = ? AND e2.form_field = ? AND e1."
65
. $pos_det['type'] . "_value = ? AND e2." . $end_det['type'] . "_value IS NULL", array('integer'),
66
array( $pos_det['id'], $end_det['id'], $position ), array( 'integer', 'integer', 'integer' ) );
68
if ( !I2CE::pearError( $row, "Errr getting person position ids: " ) ) {
69
$record = $row->record;
71
$form_data = I2CE_Form::getFormData( $record );
73
return array( 'record' => $record, 'parent' => $form_data['parent'] );
82
public function getSalaryGradeID() {
83
$pos_det = I2CE_FormField::getFormFieldIdAndType( "person_position", "position" );
84
$job_det = I2CE_FormField::getFormFieldIdAndType( "position", "job" );
85
$sg_det = I2CE_FormField::getFormFieldIdAndType( "job", "salary_grade" );
87
"SELECT e2.integer_value FROM last_entry e2 " .
88
"JOIN last_entry e3 ON e2.record = e3.integer_value " .
89
"JOIN last_entry e4 on e3.record = e4.integer_value " .
90
"WHERE e2.form_field= ? AND e3.form_field = ? ".
91
" AND e4.form_field = ? AND e4.record = ?";
92
$db =& MDB2::singleton();
93
$row =& $db->getRow($qry,
95
array($sg_det['id'],$job_det['id'],$pos_det['id'],$this->getId()),
96
array('integer','integer','integer','integer'));
98
return $row->integer_value;
104
* Constant value for employed
106
const STATUS_EMPLOYED =1;
108
* Constant value for not employed
110
const STATUS_NOT_EMPLOYED = 2;
112
* @var array Employment Status
114
static public $stati = array( self::STATUS_EMPLOYED => 'Employed', self::STATUS_NOT_EMPLOYED => 'Not Employed' );
118
* Lookup the given value from the gender array.
120
* @param string $form Not used for this method.
123
static public function lookupStatus( $id, $form="" ) {
124
return I2CE_Form::lookupArray( $id, self::$stati );
127
* List all the options from the gender array.
128
* @param string $form The form we wish to lookup by
131
static public function listStatusOptions($form ) {
132
return self::$stati ;
139
# c-default-style: "bsd"
140
# indent-tabs-mode: nil