id=$id+0; // id de la notice $this->fetch_data(); } function fetch_data() { global $dbh; $this->onglets_info=array(); $this->onglets_auth_list=array(); $authpersos = new authpersos(); // infos des autorités existantes $this->onglets_info=$authpersos->get_onglet_list(); if(!$this->id) return; // pour chaque autorités existantes récupérér les autorités affectés à la notice $req="select * from authperso, notices_authperso,authperso_authorities where id_authperso=authperso_authority_authperso_num and notice_authperso_authority_num=id_authperso_authority and notice_authperso_notice_num=".$this->id." order by notice_authperso_order"; $res = pmb_mysql_query($req,$dbh); while(($r=pmb_mysql_fetch_object($res))) { // get isbd ... $this->auth_info[$r->notice_authperso_authority_num]['onglet_num']=$r->authperso_notice_onglet_num; $this->auth_info[$r->notice_authperso_authority_num]['authperso_name']=$r->authperso_name; $this->auth_info[$r->notice_authperso_authority_num]['infos_global']=$r->authperso_infos_global; $this->auth_info[$r->notice_authperso_authority_num]['index_infos_global']=$r->authperso_index_infos_global; $authperso = new authperso($r->id_authperso); $isbd=$authperso->get_isbd($r->notice_authperso_authority_num); $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['id']=$r->notice_authperso_authority_num; $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['isbd']=$isbd; $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['authperso_name']=$r->authperso_name; $info_fields=$authperso->get_info_fields($r->notice_authperso_authority_num); $this->auth_info[$r->notice_authperso_authority_num]['isbd']=$isbd; $this->auth_info[$r->notice_authperso_authority_num]['info_fields']=$info_fields; //printr($info_fields); } } function get_notice_display(){ global $pmb_url_base; $aff=""; foreach($this->onglets_auth_list as $onglet_num => $onglet){ $authperso_name=""; foreach($onglet as $authperso_num => $auth_perso){ foreach($auth_perso as $auth_num => $auth){ if($authperso_name!=$auth['authperso_name']){ $authperso_name=$auth['authperso_name']; $aff.="
".$authperso_name." : "; $new=1; } if(!$new) $aff.=", "; $aff.= ''.$auth['isbd'].''; $new=0; } } } return $aff; } function get_notice_display_list(){ $aff_list=array(); foreach($this->onglets_auth_list as $onglet_num => $onglet){ $authperso_name=""; foreach($onglet as $authperso_num => $auth_perso){ $aff_list[$authperso_num]['isbd']=""; $aff_list[$authperso_num]['name']=""; foreach($auth_perso as $auth_num => $auth){ $aff_list[$authperso_num]['name']=$auth['authperso_name']; if($aff_list[$authperso_num]['isbd'])$aff_list[$authperso_num]['isbd'].=", "; $aff_list[$authperso_num]['isbd'].=$auth['isbd']; } } } return $aff_list; } function get_index_fields(){ $index_fields=array(); foreach($this->auth_info as $auth){ foreach($auth['info_fields'] as $field){ // printr($field); if($field['search'] ){ $index_fields[$field['code_champ']]['pond']=$field['pond']; if($field['all_format_values']) $index_fields[$field['code_champ']]['ss_champ'][][$field['code_ss_champ']].=$field['all_format_values']; } } } return $index_fields; } function get_index_fields_to_delete(){ return authpersos::get_all_index_fields(); } function get_form(){ global $msg,$charset,$base_path; $onglet_all_tpl=" "; $authperso_notice_onglet_tpl="

!!onglet_name!!

!!authperso_list!!

"; $authperso_notice_elt_tpl= "
!!authlist!!
"; $authperso_notice_elt_tpl_num="
"; foreach($this->onglets_info as $onglet_num => $onglet){ $onglet_contens=""; foreach($onglet as $elt){ // Pour chaque type d'autorité dans l'onglet //printr($elt); $tpl_elt=$authperso_notice_elt_tpl; $iauthperso=0; $auth_list_tpl=""; $tab_authperso_order=array(); if(!count($this->onglets_auth_list[$onglet_num][$elt['id']])){ // pas d'autorité $auth_list_tpl=$authperso_notice_elt_tpl_num; $auth_list_tpl=str_replace('!!authperso_libelle!!',"", $auth_list_tpl); $auth_list_tpl=str_replace('!!iauthperso!!',$iauthperso, $auth_list_tpl); $auth_list_tpl=str_replace('!!auth_id!!',"", $auth_list_tpl); $max_authperso=1; $tab_authperso_order[]="authperso_".$elt['id']."_0"; }else{ foreach ($this->onglets_auth_list[$onglet_num][$elt['id']] as $auth_id =>$auth){ // Pour chaque autorité répétée $auth_tpl=$authperso_notice_elt_tpl_num; $auth_tpl=str_replace('!!authperso_libelle!!',$auth['isbd'], $auth_tpl); $auth_tpl=str_replace('!!iauthperso!!',$iauthperso, $auth_tpl); $auth_tpl=str_replace('!!auth_id!!',$auth_id, $auth_tpl); $auth_list_tpl.=$auth_tpl; $tab_authperso_order[]="authperso_".$elt['id']."_".$iauthperso; $iauthperso++; $max_authperso=$iauthperso; } } $tpl_elt=str_replace('!!authlist!!',$auth_list_tpl, $tpl_elt); $tpl_elt=str_replace('!!auth_name!!',htmlentities($elt['name'], ENT_QUOTES, $charset), $tpl_elt); $tpl_elt=str_replace('!!authperso_id!!',$elt['id'], $tpl_elt); $tpl_elt=str_replace('!!iauthperso!!',0, $tpl_elt); $tpl_elt=str_replace('!!max_authperso!!',$max_authperso, $tpl_elt); $tpl_elt=str_replace('!!tab_authperso_order!!',implode(",",$tab_authperso_order), $tpl_elt); $onglet_contens.=$tpl_elt; } $onglet_tpl=$authperso_notice_onglet_tpl; $onglet_tpl=str_replace('!!authperso_list!!',$onglet_contens, $onglet_tpl); $onglet_tpl=str_replace('!!onglet_name!!',$elt['onglet_name'], $onglet_tpl); $onglet_tpl=str_replace('!!ongletnum!!',$onglet_num, $onglet_tpl); $onglet_all_tpl.=$onglet_tpl; } return $onglet_all_tpl; } function delete(){ global $dbh; $req="delete from notices_authperso where notice_authperso_notice_num=".$this->id; pmb_mysql_query($req, $dbh); } function save_form(){ global $dbh; $authpersos = new authpersos(); $infos=$authpersos->get_data(); if(!count($infos)) return; $this->delete(); foreach ($infos as $authperso){ $authperso_id=$authperso['id']; $max_authperso="max_authperso_".$authperso_id; global $$max_authperso; $max_authperso=$$max_authperso; $order=0; $tab_authperso_order="tab_authperso_order_".$authperso_id; global $$tab_authperso_order; $tab_authperso_order=$$tab_authperso_order; // value="authperso_1_2,authperso_1_0,authperso_1_1" .... $tab_order=explode(',',$tab_authperso_order); foreach($tab_order as $string_order){ $tab_string_order=explode("_",$string_order); $final_ordre[]=$tab_string_order[2]; } if($final_ordre){ $order=0; foreach($final_ordre as $old_order){ $auth_id="f_authperso_id_".$authperso_id."_".$old_order; global $$auth_id; $auth_id=$$auth_id; if($auth_id){ $req="insert into notices_authperso set notice_authperso_notice_num=".$this->id.", notice_authperso_authority_num= $auth_id, notice_authperso_order=".$order; $result = pmb_mysql_query($req, $dbh); $order++; } } }else{ $order=0; for($i=0;$i<$max_authperso; $i++ ){ $auth_id="f_authperso_id_".$authperso_id."_".$i; global $$auth_id; $auth_id=$$auth_id; if($auth_id){ $req="insert into notices_authperso set notice_authperso_notice_num=".$this->id.", notice_authperso_authority_num= $auth_id, notice_authperso_order=".$order; $result = pmb_mysql_query($req, $dbh); $order++; } } } } } function get_fields_search(){ $mots=""; foreach($this->auth_info as $auth){ if($mots)$mots.=" "; $mots.=$auth["infos_global"]; } return $mots; } } // authperso_notice class end