";
if ($r->exclusion_obligatoire==1) $res.=$msg["40"];
else $res.=$msg["39"];
$res.="
";
}
$res.="
\n";
}
$res.="
";
$form_list=str_replace("!!liste_champs_perso!!",$res,$form_list);
$form_list=str_replace("!!base_url!!",$this->base_url,$form_list);
}
//ajout d'un bouton retour à la liste...
if(strpos($row->editorial_type_element,"generic")!== false){
$base_url = str_replace($row->editorial_type_element,substr($row->editorial_type_element,0,strpos($row->editorial_type_element,"_")),$this->base_url);
}else{
$base_url = $this->base_url;
}
$form_list.= " ";
return $form_list;
}
//Récupération des valeurs stockées dans les base pour un emprunteur ou autre
function get_out_values($id) {
//Récupération des valeurs stockées
if ((!$this->no_special_fields)&&($id)) {
$this->values = array() ;
$requete="select ".$this->prefix."_custom_champ,".$this->prefix."_custom_origine,".$this->prefix."_custom_small_text, ".$this->prefix."_custom_text, ".$this->prefix."_custom_integer, ".$this->prefix."_custom_date, ".$this->prefix."_custom_float from ".$this->prefix."_custom_values join ".$this->prefix."_custom on idchamp=".$this->prefix."_custom_champ and num_type = ".$this->num_type." where ".$this->prefix."_custom_origine=".$id;
$resultat=mysql_query($requete);
while ($r=mysql_fetch_array($resultat)) {
$this->values[$this->t_fields[$r[$this->prefix."_custom_champ"]]["NAME"]]['label'] = $this->t_fields[$r[$this->prefix."_custom_champ"]]["TITRE"];
$this->values[$this->t_fields[$r[$this->prefix."_custom_champ"]]["NAME"]]['id'] = $r[$this->prefix."_custom_champ"];
$this->values[$this->t_fields[$r[$this->prefix."_custom_champ"]]["NAME"]]['values'][] = array(
'value' => $r[$this->prefix."_custom_".$this->t_fields[$r[$this->prefix."_custom_champ"]]["DATATYPE"]],
'format_value' => $this->get_formatted_output(array($r[$this->prefix."_custom_".$this->t_fields[$r[$this->prefix."_custom_champ"]]["DATATYPE"]]),$r[$this->prefix."_custom_champ"],true)
);
}
} else $this->values=array();
return $this->values;
}
public function delete_all(){
$query = "select idchamp from ".$this->prefix."_custom where num_type = ".$this->num_type;
$result = mysql_query($query);
if(mysql_num_rows($result)){
while ($row = mysql_fetch_object($result)){
$requete="delete from ".$this->prefix."_custom where idchamp=$row->idchamp";
mysql_query($requete);
$requete="delete from ".$this->prefix."_custom_values where ".$this->prefix."_custom_champ=$row->idchamp";
mysql_query($requete);
$requete="delete from ".$this->prefix."_custom_lists where ".$this->prefix."_custom_champ=$row->idchamp";
mysql_query($requete);
}
}
}
//Suppression de la base des valeurs d'un emprunteur ou autre...
function delete_values($id) {
// on récupère la liste des champs associés...
$query = "select idchamp from ".$this->prefix."_custom where num_type = ".$this->num_type;
$result = mysql_query($query);
$idchamp = "";
if(mysql_num_rows($result)){
while($row = mysql_fetch_object($result)){
if($idchamp) $idchamp.=",";
$idchamp.=$row->idchamp;
}
}
if(!$idchamp) $idchamp="''";
$requete = "DELETE FROM ".$this->prefix."_custom_values where ".$this->prefix."_custom_champ in (".$idchamp.") and ".$this->prefix."_custom_origine=$id";
$res = mysql_query($requete);
}
//Récupération des valeurs stockées dans les base pour un emprunteur ou autre
function get_values($id) {
//Récupération des valeurs stockées pour l'emprunteur
if ((!$this->no_special_fields)&&($id)) {
$this->values=$this->list_values=array();
$requete="select ".$this->prefix."_custom_champ,".$this->prefix."_custom_origine,".$this->prefix."_custom_small_text, ".$this->prefix."_custom_text, ".$this->prefix."_custom_integer, ".$this->prefix."_custom_date, ".$this->prefix."_custom_float from ".$this->prefix."_custom_values join ".$this->prefix."_custom on idchamp=".$this->prefix."_custom_champ and num_type = ".$this->num_type." where ".$this->prefix."_custom_origine=".$id;
$resultat=mysql_query($requete);
while ($r=mysql_fetch_array($resultat)) {
$this->values[$r[$this->prefix."_custom_champ"]][]=$r[$this->prefix."_custom_".$this->t_fields[$r[$this->prefix."_custom_champ"]]["DATATYPE"]];
$this->list_values[]=$r[$this->prefix."_custom_".$this->t_fields[$r[$this->prefix."_custom_champ"]]["DATATYPE"]];
}
} else $this->values=$this->list_values=array();
}
//Affichage des champs à saisir dans le formulaire de modification/création d'un emprunteur ou autre
function show_editable_fields($id,$type="") {
global $aff_list_empr,$charset;
$perso=array();
//on va chercher les champs génériques
$generic_type = $this->get_generic_type($type);
if($generic_type){
$generic = new cms_editorial_parametres_perso($generic_type,$this->base_url);
$p = $generic->show_editable_fields($id);
$perso['FIELDS'] = $p['FIELDS'];
$perso['CHECK_SCRIPTS'] = $p['CHECK_SCRIPTS'];
}
if (!$this->no_special_fields) {
$this->get_values($id);
$check_scripts="";
reset($this->t_fields);
while (list($key,$val)=each($this->t_fields)) {
$t=array();
$t["NAME"]=$val["NAME"];
$t["TITRE"]=$val["TITRE"];
$field=array();
$field["ID"]=$key;
$field["NAME"]=$this->t_fields[$key]["NAME"];
$field["MANDATORY"]=$this->t_fields[$key]["MANDATORY"];
$field["SEARCH"]=$this->t_fields[$key]["SEARCH"];
$field["EXPORT"]=$this->t_fields[$key]["EXPORT"];
$field["EXCLUSION"]=$this->t_fields[$key]["EXCLUSION"];
$field["OPAC_SORT"]=$this->t_fields[$key]["OPAC_SORT"];
$field["ALIAS"]=$this->t_fields[$key]["TITRE"];
$field["DATATYPE"]=$this->t_fields[$key]["DATATYPE"];
$field["OPTIONS"][0]=_parser_text_no_function_("\n".$this->t_fields[$key]["OPTIONS"], "OPTIONS");
$field["VALUES"]=$this->values[$key];
$field["PREFIX"]=$this->prefix;
eval("\$aff=".$aff_list_empr[$this->t_fields[$key][TYPE]]."(\$field,\$check_scripts);");
$t["AFF"]=$aff;
$t["NAME"]=$field["NAME"];
$perso["FIELDS"][]=$t;
}
//Compilation des javascripts de validité renvoyés par les fonctions d'affichage
$check_scripts="";
$perso["CHECK_SCRIPTS"]=$check_scripts;
} else
$perso["CHECK_SCRIPTS"]="";
return $perso;
}
//Enregistrement des champs perso soumis lors de la saisie d'une fichie emprunteur ou autre...
function rec_fields_perso($id,$type="") {
$this->check_submited_fields();
$query = "select editorial_type_element from cms_editorial_types where id_editorial_type=".$this->num_type;
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$requete="delete ".$this->prefix."_custom_values from ".$this->prefix."_custom_values
join cms_editorial_custom on cms_editorial_custom_champ = idchamp
join cms_editorial_types on num_type=id_editorial_type
and editorial_type_element = '".mysql_result($result,0,0)."'
where ".$this->prefix."_custom_origine=$id";
mysql_query($requete);
}
if($type){
//Enregistrement des champs personalisés
//on va chercher les champs génériques
$generic_type = $this->get_generic_type($type);
if($generic_type){
$generic = new cms_editorial_parametres_perso($generic_type,$this->base_url);
$generic->rec_fields_perso($id);
}
}
reset($this->t_fields);
while (list($key,$val)=each($this->t_fields)) {
$name=$val["NAME"];
global $$name;
$value=$$name;
for ($i=0; $iprefix."_custom_values (".$this->prefix."_custom_champ,".$this->prefix."_custom_origine,".$this->prefix."_custom_".$val["DATATYPE"].") values($key,$id,'".$value[$i]."')";
mysql_query($requete);
}
}
}
}
//Duplication des champs perso d'un contenu éditorial...
function duplicate_fields_perso($id,$duplicate_from_id, $type = "") {
global $dbh;
if($type){
//Enregistrement des champs personalisés
//on va chercher les champs génériques
$generic_type = $this->get_generic_type($type);
if($generic_type){
$generic = new cms_editorial_parametres_perso($generic_type);
$requete="select ".$generic->prefix."_custom_champ,".$generic->prefix."_custom_origine,".$generic->prefix."_custom_small_text, ".$generic->prefix."_custom_text, ".$generic->prefix."_custom_integer, ".$generic->prefix."_custom_date, ".$generic->prefix."_custom_float from ".$generic->prefix."_custom_values join ".$generic->prefix."_custom on idchamp=".$generic->prefix."_custom_champ and num_type = ".$generic_type." where ".$generic->prefix."_custom_origine=".$duplicate_from_id;
$resultat=mysql_query($requete,$dbh);
while ($r=mysql_fetch_array($resultat)) {
$requete="insert into ".$generic->prefix."_custom_values (".$generic->prefix."_custom_champ,".$generic->prefix."_custom_origine,".$generic->prefix."_custom_small_text, ".$generic->prefix."_custom_text, ".$generic->prefix."_custom_integer, ".$generic->prefix."_custom_date, ".$generic->prefix."_custom_float)
values(".$r[$generic->prefix."_custom_champ"].",".$id.",'".$r[$generic->prefix."_custom_small_text"]."','".$r[$generic->prefix."_custom_text"]."','".$r[$generic->prefix."_custom_integer"]."','".$r[$generic->prefix."_custom_date"]."','".$r[$generic->prefix."_custom_float"]."')";
mysql_query($requete,$dbh);
}
}
}
$requete="select ".$this->prefix."_custom_champ,".$this->prefix."_custom_origine,".$this->prefix."_custom_small_text, ".$this->prefix."_custom_text, ".$this->prefix."_custom_integer, ".$this->prefix."_custom_date, ".$this->prefix."_custom_float from ".$this->prefix."_custom_values join ".$this->prefix."_custom on idchamp=".$this->prefix."_custom_champ and num_type = ".$this->num_type." where ".$this->prefix."_custom_origine=".$duplicate_from_id;
$resultat=mysql_query($requete,$dbh);
while ($r=mysql_fetch_array($resultat)) {
$requete="insert into ".$this->prefix."_custom_values (".$this->prefix."_custom_champ,".$this->prefix."_custom_origine,".$this->prefix."_custom_small_text, ".$this->prefix."_custom_text, ".$this->prefix."_custom_integer, ".$this->prefix."_custom_date, ".$this->prefix."_custom_float)
values(".$r[$this->prefix."_custom_champ"].",".$id.",'".$r[$this->prefix."_custom_small_text"]."','".$r[$this->prefix."_custom_text"]."','".$r[$this->prefix."_custom_integer"]."','".$r[$this->prefix."_custom_date"]."','".$r[$this->prefix."_custom_float"]."')";
mysql_query($requete,$dbh);
}
}
public function get_generic_type($type){
$generic_type = 0;
if($type){
$query = "select id_editorial_type from cms_editorial_types where editorial_type_element like '".$type."_generic'";
$result = mysql_query($query);
if(mysql_num_rows($result)){
$row = mysql_fetch_object($result);
$generic_type = $row->id_editorial_type;
}
}
return $generic_type;
}
public function get_formatted_output($values, $field_id, $keep_html=false){
global $val_list_empr, $charset;
$field=array();
$field["ID"]=$field_id;
$field["NAME"]=$this->t_fields[$field_id]["NAME"];
$field["MANDATORY"]=$this->t_fields[$field_id]["MANDATORY"];
$field["OPAC_SORT"]=$this->t_fields[$field_id]["OPAC_SORT"];
$field["ALIAS"]=$this->t_fields[$field_id]["TITRE"];
$field["DATATYPE"]=$this->t_fields[$field_id]["DATATYPE"];
$field["OPTIONS"][0]=_parser_text_no_function_("\n".$this->t_fields[$field_id]["OPTIONS"], "OPTIONS");
$field["VALUES"]=$values;
$field["PREFIX"]=$this->prefix;
$aff=$val_list_empr[$this->t_fields[$field_id]["TYPE"]]($field,$values);
if(is_array($aff)){
if($keep_html){
return $aff['value'];
}else return $aff['withoutHTML'];
}
else return $aff;
}
}