db=$p_cn;
$this->frd_id=$p_frd_id;
$this->attribut=array('frd_id','frd_text','frd_class_base');
}
/*!
**************************************************
* \brief Load all the fiche_def_ref data and
* return an array of fiche_def_ref objects
*
* \return array
*/
function LoadAll()
{
$sql="select * from fiche_def_ref order by frd_id";
$Res=$this->db->exec_sql($sql);
$all=Database::fetch_all($Res);
if ( $Res == false ) return array();
$idx=0;
$array=array();
foreach ($all as $row)
{
$o=new Fiche_Def_Ref($this->db);
foreach ( $this->attribut as $value)
{
$o->$value=$row[$value];
}
$array[$idx]=$o;
$idx++;
}
return $array;
}
/*!
**************************************************
* \brief Display data between
tag
*
* \return string
*/
function Display()
{
$r="";
foreach ( $this->attribut as $value)
{
$r.=" | ".$this->$value.' | ';
}
return $r;
}
/*!
**************************************************
* \brief Input Data between tag
*
* \return string
*/
function Input()
{
$r="";
$h=new IHidden();
$r.='Id :'.$h->input('frd_id',$this->frd_id).$this->frd_id."";
$w=new IText();
$r.=''._('Commentaire ').' :'.$w->input('frd_text',$this->frd_text)."";
$t=new IText();
$r.=''._('Poste de base').':'.$t->input('frd_class_base',$this->frd_class_base)."";
return $r;
}
/*!
**************************************************
* \brief Store data into the database: update the
* record
*
* -
* \return none
*/
function Save()
{
$sql="update fiche_def_ref set frd_text=$1 ".
" , frd_class_base=$2 ".
" where frd_id= $3";
$Res=$this->db->exec_sql($sql,array($this->frd_text,$this->frd_class_base,$this->frd_id));
}
/*!
**************************************************
* \brief Get the data with the p_code and complete
* the current object
*
* \return none
*/
function Get()
{
$sql="select * from fiche_def_ref ".
" where frd_id=".$this->frd_id;
$Res=$this->db->exec_sql($sql);
if ( Database::num_row($Res) == 0 ) return null;
$r=Database::fetch_array($Res,0);
$this->frd_text=$r['frd_text'];
$this->frd_class_base=$r['frd_class_base'];
}
/**
* get category of cards by model
* @param $p_modele if the FRD_ID
* @return array of category (fd_id)
*/
function get_by_modele($p_modele)
{
$array = array();
$result = $this->db->get_array('select fd_id from fiche_def where frd_id=$1', array($p_modele));
for ($i = 0; $i < count($result); $i++)
{
$array[$i] = $result[$i]['fd_id'];
}
return $array;
}
}
?>
|