id=$id_serialcirc+0; $this->fetch_data(); } function fetch_data() { $this->p_perso = new parametres_perso("empr"); $this->circ_tpl=array(); $requete="select * from serialcirc where id_serialcirc=".$this->id ; $resultat=mysql_query($requete); if (mysql_num_rows($resultat)) { $r=mysql_fetch_object($resultat); if($r->serialcirc_tpl) { $this->circ_tpl=stripslashes_array(unserialize($r->serialcirc_tpl)); } } } 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); } function get_line($data){ $elt=array(); if($data['empr_id']){ $req="select * from empr where id_empr=".$data['empr_id']; $res_empr=mysql_query($req); $empr=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']){ $elt[]=$pp_data['AFF']; $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; default :$elt[]=" "; break; } } return $elt; } function get_select_form($name="select_field",$selected=0,$onchange="serialcirc_print_add_button();") { global $charset,$msg,$base_path; $sel="
!!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; } 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; } } function save_form(){ global $field_list; $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))."' where id_serialcirc=".$this->id ; mysql_query($req); $this->fetch_data(); } 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 ; mysql_query($req); $this->fetch_data(); } 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 ; mysql_query($req); $this->fetch_data(); } 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 ; mysql_query($req); $this->fetch_data(); } } //serialcirc class end