id=$id_serialcirc+0; $this->fetch_data(); } public function fetch_data() { global $dbh; $this->p_perso = new parametres_perso("empr"); $this->circ_tpl=array(); $this->piedpage=""; $requete="select * from serialcirc where id_serialcirc=".$this->id ; $resultat=pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)) { $r=pmb_mysql_fetch_object($resultat); if($r->serialcirc_tpl) { //On va récupérer le template prédéfini if (intval($r->serialcirc_tpl) > 0) { $query = "select * from serialcirc_tpl where serialcirctpl_id=".$r->serialcirc_tpl; $res = pmb_mysql_query($query,$dbh); if ($res) { $row=pmb_mysql_fetch_object($res); if($row->serialcirctpl_tpl) { $this->circ_tpl=stripslashes_array(unserialize($row->serialcirctpl_tpl)); $this->piedpage=$row->serialcirctpl_piedpage; } } } else { $this->circ_tpl=stripslashes_array(unserialize($r->serialcirc_tpl)); $this->piedpage=$r->serialcirc_piedpage; } } } } static public function get_default_tpl() { $tpl = ''; $requete="select serialcirctpl_tpl FROM serialcirc_tpl WHERE serialcirctpl_id=1"; $res=pmb_mysql_query($requete); if (pmb_mysql_num_rows($res)) { $row=pmb_mysql_fetch_object($res); $tpl=stripslashes_array(unserialize($row->serialcirctpl_tpl)); } return $tpl; } public function get_header_list(){ $header_list=array(); foreach($this->circ_tpl as $cpt => $line){ if($line['type']=="libre"){ $header_list[]=$line['label']; }else { $header_list[]=$this->get_field_label($line['type'],$line['id']); } } return($header_list); } public function get_line($data){ global $charset; $elt=array(); if($data['empr_id']){ $req="SELECT empr.*, empr_statut.statut_libelle, empr_categ.libelle as libelle_categ, empr_codestat.libelle as libelle_codestat, docs_location.location_libelle, GROUP_CONCAT(distinct libelle_groupe) as group_name FROM empr_statut, empr_categ, empr_codestat, docs_location, empr LEFT JOIN empr_groupe ON (empr.id_empr=empr_groupe.empr_id) LEFT JOIN groupe on (groupe.id_groupe=empr_groupe.groupe_id) WHERE empr.empr_categ=empr_categ.id_categ_empr AND empr.empr_statut=empr_statut.idstatut AND empr.empr_codestat=empr_codestat.idcode AND empr.empr_location=docs_location.idlocation AND empr.id_empr=".$data['empr_id']; $res_empr=pmb_mysql_query($req); $empr=pmb_mysql_fetch_object($res_empr); $pp=$this->p_perso->show_fields($data['empr_id']); } foreach($this->circ_tpl as $cpt => $line){ switch($line['type']){ case 'pp': $found=0; foreach($pp['FIELDS'] as $pp_data){ if($pp_data['ID']==$line['id']){ //on décode les entités html puis toutes les valeur sont réencodées à l'affichage $elt[]=html_entity_decode($pp_data['AFF'],ENT_QUOTES,$charset); $found=1; } } if(!$found)$elt[]=" "; break; case "name":$elt[]= $empr->empr_nom; break; case "emprlibelle":$elt[]= $empr->empr_nom." ".$empr->empr_prenom; break; case "cb":$elt[]=$empr->empr_cb; break; case "mail":$elt[]=$empr->empr_mail; break; case "adr1":$elt[]=$empr->empr_adr1; break; case "adr2":$elt[]=$empr->empr_adr2; break; case "tel1":$elt[]=$empr->empr_tel1; break; case "tel2":$elt[]=$empr->empr_tel2; break; case "ville":$elt[]=$empr->empr_ville; break; case "libre":$elt[]=" "; break; case "statut":$elt[]=$empr->statut_libelle; break; case "categ":$elt[]=$empr->libelle_categ; break; case "codestat":$elt[]=$empr->libelle_codestat; break; case "groupe":$elt[]=$empr->group_name; break; case "loc":$elt[]=$empr->location_libelle; break; default :$elt[]=" "; break; } } return $elt; } public function get_select_form($name="select_field",$selected=0,$onchange="serialcirc_print_add_button();") { global $charset,$msg,$base_path; $sel=htmlentities($msg["serialcirc_diff_option_form_fiche_format_add_field"], ENT_QUOTES, $charset)."
!!fiche_fields!!
"; $perso_fields=""; if(count($this->p_perso->t_fields ))$perso_fields=""; foreach($this->p_perso->t_fields as $id =>$p){ $perso_fields.=""; } $sel=str_replace('!!empr_param_perso!!', $perso_fields, $sel); $line_tpl="
!!titre_field!!
"; $tpl_list=""; $index=0; foreach($this->circ_tpl as $cpt => $line){ $tpl=$line_tpl; $titre_field=$this->get_field_label($line['type'],$line['id']); $tpl=str_replace('!!titre_drag!!',$titre_field , $tpl); if(!$line['id'])$line['id']=0; $name=$line['type']."_".$cpt."_".$line['id']; if($line['type']=="libre") $titre_field.=""; $titre_field.=""; $tpl=str_replace('!!titre_field!!',$titre_field , $tpl); $tpl=str_replace('!!index!!',$index , $tpl); $tpl_list.=$tpl; $index++; } $sel=str_replace('!!fiche_fields!!', $tpl_list, $sel); return $sel; } public function get_field_label($field,$id=0){ global $msg; switch($field){ case "name": return $msg["serialcirc_print_empr_name"]; break; case "emprlibelle": return $msg["serialcirc_print_empr_libelle"]; break; case "cb": return $msg["serialcirc_print_empr_cb"]; break; case "adr1": return $msg["serialcirc_print_empr_adr1"]; break; case "adr2": return $msg["serialcirc_print_empr_adr2"]; break; case "tel1": return $msg["serialcirc_print_empr_tel1"]; break; case "tel2": return $msg["serialcirc_print_empr_tel2"]; break; case "ville": return $msg["serialcirc_print_empr_ville"]; break; case "libre": return $msg["serialcirc_print_libre_fields"]; break; case "pp": if(count($this->p_perso->t_fields )){ if($this->p_perso->t_fields[$id]){ return $this->p_perso->t_fields[$id]["TITRE"]; } } break; case "categ" : return $msg["serialcirc_print_empr_categ"]; break; case "statut" : return $msg["serialcirc_print_empr_statut"]; break; case "codestat" : return $msg["serialcirc_print_empr_codestat"]; break; case "groupe" : return $msg["serialcirc_print_empr_groupe"]; break; case "loc" : return $msg["serialcirc_print_empr_loc"]; break; } } public function save_form(){ global $field_list,$piedpage,$fiche_tpl_id_sel; if ($fiche_tpl_id_sel) { $req="update serialcirc set serialcirc_tpl='".$fiche_tpl_id_sel."', serialcirc_piedpage='$piedpage' where id_serialcirc=".$this->id ; pmb_mysql_query($req); } else { $this->circ_tpl=array(); $cpt=0; if(!$field_list)$field_list=array(); foreach($field_list as $field){ $data=explode('_',$field); $this->circ_tpl[$cpt]['type']=$data[0]; $this->circ_tpl[$cpt]['id']=$data[2]; $val_label=$field."_label"; global ${$val_label}; $this->circ_tpl[$cpt]['label']= ${$val_label}; $cpt++; } $req="update serialcirc set serialcirc_tpl='".addslashes(serialize($this->circ_tpl))."', serialcirc_piedpage='$piedpage' where id_serialcirc=".$this->id ; pmb_mysql_query($req); } $this->fetch_data(); } public function up_order($tablo){ global $dbh; $liste = explode(",",$tablo); $new_circ_tpl=array(); for($i=0;$icirc_tpl[$liste[$i]]; } $req="update serialcirc set serialcirc_tpl='".addslashes(serialize($new_circ_tpl))."' where id_serialcirc=".$this->id ; pmb_mysql_query($req); $this->fetch_data(); } public function add_field(){ global $select_field; $cpt=count($this->circ_tpl); $data=explode('_',$select_field); $this->circ_tpl[$cpt]['type']=$data[0]; $this->circ_tpl[$cpt]['id']=$data[1]; $req="update serialcirc set serialcirc_tpl='".addslashes(serialize($this->circ_tpl))."' where id_serialcirc=".$this->id ; pmb_mysql_query($req); $this->fetch_data(); } public function del_field(){ global $index; array_splice($this->circ_tpl,$index,1); $req="update serialcirc set serialcirc_tpl='".addslashes(serialize($this->circ_tpl))."' where id_serialcirc=".$this->id ; pmb_mysql_query($req); $this->fetch_data(); } public function change_fields(){ global $dbh, $form_serialcirc_tpl; if ($form_serialcirc_tpl) { $requete = "select serialcirctpl_tpl from serialcirc_tpl where serialcirctpl_id=".$form_serialcirc_tpl; $result = pmb_mysql_query($requete,$dbh); if ($result) { if (pmb_mysql_num_rows($result) == 1) { $req="update serialcirc set serialcirc_tpl='".$form_serialcirc_tpl."' where id_serialcirc=".$this->id; pmb_mysql_query($req,$dbh); } } } else { $req="update serialcirc set serialcirc_tpl='' where id_serialcirc=".$this->id; pmb_mysql_query($req,$dbh); } $this->fetch_data(); } public function get_sort_form($name="sort_field",$selected=0,$onchange="serialcirc_diff_sort_button();") { global $charset,$msg,$base_path; $sel="
".$msg["sort_label"]." :
"; $perso_fields=""; if(count($this->p_perso->t_fields ))$perso_fields=""; foreach($this->p_perso->t_fields as $id =>$p){ $perso_fields.=""; } $sel=str_replace('!!empr_param_perso!!', $perso_fields, $sel); return $sel; } } //serialcirc class end