';
$display.=dossier::hidden();
// Number of line of the card
$display.='';
// Table of input
$display.='
';
//Name of the CARD (fiche_def.fd_label)
$display.='
Catégorie de fiche
';
$display.='
';
$display.='
';
// Class base fiche_def.fd_class_base (optional)
$display.='
Classe de base
';
$display.='
'.$p_js;
$display.='
';
// Checkbox for the creation of a post
$display.='
Création automatique du poste comptable
';
//display the different template
$ref=Get_fiche_def_ref($p_cn);
// check if $ref is an array
// and display the choice
// select by default the first choice
$check="CHECKED";
if ( sizeof($ref) ) {
foreach ($ref as $i=>$v) {
$display.='
';
$display.='';
$display.=$v['text'];
// if a class base exist in fiche_def_ref, we display it
if ( sizeof ($v['class']) != 0 )
$display.="  Class base = ".$v['class']."";
$display.="
";
$check="";
}
}
// closing the form
$display.='
';
$display.='';
$display.='';
// display it
echo $display;
}
/*! getFicheName
***************************************************
* \brief retourne le nom de la fiche
* en fournissant le quick_code
*
*
* \param p_cn connexion
* \param p_id quick_code
*
*/
function getFicheName($p_cn,$p_id) {
// Retrieve the attribute with the ad_id 1
// 1 is always the name
$p_id=FormatString($p_id);
$fiche=new fiche($p_cn);
$fiche->get_by_qcode($p_id);
return $fiche->strAttribut(ATTR_DEF_NAME);
}
/*! Get_fiche_def_ref
***************************************************
* \brief
* return an array containing all the
* data contained in the table fiche_def_ref
* parm :
* - $p_cn connection to the database
* gen :
* - none
* return:
* array if ok null otherwize
*/
function Get_fiche_def_ref($p_cn)
{
// get all the data from fiche_def_ref
$Res=ExecSql($p_cn, "select frd_id,frd_text,frd_class_base
from fiche_def_ref
order by frd_text");
// check if the result is valid
$Max=pg_NumRows($Res);
if ( $Max == 0) return null;
// store the result in a array
for ($i=0;$i<$Max;$i++) {
$f=pg_fetch_array($Res,$i);
$array[$i]['id']=$f['frd_id'];
$array[$i]['text']=$f['frd_text'];
$array[$i]['class']=$f['frd_class_base'];
}
// return result
return $array;
}
/*! Get_attr_min
***************************************************
* \brief retrieve the mandatory field of the card model
*
* \param $p_cn database connexion
* \param $p_fiche_def_ref
* \return array of ad_id (attr_min.ad_id) and labels (attr_def.ad_text)
*
*/
function Get_attr_min($p_cn,$p_fiche_def_ref) {
// find the min attr for the fiche_def_ref
$Sql="select ad_id,ad_text from attr_min natural join attr_def
natural join fiche_def_ref
where
frd_id= $p_fiche_def_ref";
$Res=ExecSql($p_cn,$Sql);
$Num=pg_NumRows($Res);
// test the number of returned rows
if ($Num == 0 ) return null;
// Get Results & Store them in a array
for ($i=0;$i<$Num;$i++) {
$f=pg_fetch_array($Res,$i);
$array[$i]['ad_id']=$f['ad_id'];
$array[$i]['ad_text']=$f['ad_text'];
}
return $array;
}
/*! getFicheAttribut
***************************************************
* \brief retrun array of attribut or string
*
* \param p_cn connexion
* \param p_id quick_code
* \param attribut if attribut == "" then return a array
* taken from vw_fiche_attr
* \return string avec nom fiche is attr is not null
* or array is attr is empty
*
*/
function getFicheAttribut($p_cn,$p_id,$p_attr="") {
$p_id=FormatString($p_id);
if ( $p_attr != "") {
$Res=ExecSql($p_cn,"select av_text from
attr_value
natural join jnt_fic_att_value
natural join fiche
where
ad_id=$p_attr
and f_id=(select f_id from vw_poste_qcode where j_qcode=upper('$p_id')) ");
if ( pg_NumRows($Res) == 0 ) return NULL;
$st=pg_fetch_array($Res,0);
return $st['av_text'];
} else {
// Get attribut from the view
$Res=ExecSql($p_cn,"select * from vw_fiche_attr where quick_code=upper('$p_id')");
if ( pg_NumRows($Res) == 0 ) return null;
$st=pg_fetch_array($Res,0);
return $st;
}
}
?>