<?php
require_once ($staticpath."classes/Students.class.php");

class DataElements extends Students
{
    var $field_name;
    var $source_table;
    var	$sel_school_id;
    var $codes_field;
    
    public function getRegistrationCodes()
    {
        $regCodes = db_request(db_execute("SELECT ID,TITLE FROM STUDENT_REGISTRATION_SETTINGS WHERE SCHOOL_YEAR = '".get_school_year()."'"),array(),array());
        $regCodes_list[''] = _('N/A');
        foreach($regCodes as $s_id=>$stitle)
        {
            $regCodes_list[$stitle['ID']] = $stitle['TITLE'];
	}
	return $regCodes_list;
    }
    public function getAdmSchools()
    {
//	    var_dump(get_apply_school_array());
	    if(get_apply_school_array())
	    {
		    $where = 'WHERE ID IN ('.implode(',',get_apply_school_array()).')';
		    $adm_schools = db_request(db_execute('SELECT ID,TITLE FROM SCHOOLS '.$where),array(),array());
		    foreach($adm_schools as $s_id=>$stitle)
		    {
			    $adm_school_list[$stitle['ID']] = $stitle['TITLE'];
		    }
		    return $adm_school_list;
	    }
	    else
		    return false;
    }

    public function getSchools()
    {
	    if(!get_apply_school_array())
		    $where = '';
	    else
		    $where = 'WHERE ID NOT IN ('.implode(',',get_apply_school_array()).')';
	    $schools = db_request(db_execute('SELECT ID,TITLE FROM SCHOOLS '.$where),array(),array());
            $school_list[''] = _('N/A');
	    foreach($schools as $s_id=>$stitle)
	    {
        
        
	    	    $school_list[$stitle['ID']] = $stitle['TITLE'];
	    }
	    return $school_list;
    }

    public function getFaculties()
    {
    
	    var_dump($this->_setFaculty_array());
//	    if(get_apply_school_array())
	    {
//		    $where = 'WHERE ID NOT IN ('.implode(',',get_apply_school_array()).')';
//		    $schools = db_request(db_execute('SELECT ID,TITLE FROM SCHOOLS '.$where),array(),array());
//		    foreach($schools as $s_id=>$stitle)
//		    {
//			    $schools[$s_id] = $stitle['TITLE'];
//		    }
//		    return $schools;
	    }
//	    else
//		    return false;
    }

    public function getSourceData22()
    {
	if($this->source_table && $this->values_field)
	{
		$data_array = db_request(db_execute('SELECT '.$this->values_field.($this->codes_field?','.$this->codes_field:'').' FROM '.$this->source_table),array(),array());
		if($data_array)
		{
			$dc = count($data_array);
			foreach($data_array as $value)
			{
				$cur++;
//				echo $value[$this->values_field];				
				$data['values'] .= $value[$this->values_field].($cur!=$dc?"\r":"");
				$data['codes'] .= $value[$this->codes_field].($cur!=$dc?"\r":"");
			}
			return $data;
		}
		else
			return false;
//		var_dump($data_array);
//var_dump($data['values']);
	}
	else
		return false;
    }
    
}
?>