id_statut = intval($id_statut); if ($this->id_statut) { $this->load(); } } // charge un statut de ligne d'acte à partir de la base. public function load(){ $q = "select * from lignes_actes_statuts where id_statut = '".$this->id_statut."' "; $r = pmb_mysql_query($q) ; if(!pmb_mysql_num_rows($r)) { pmb_error::get_instance(static::class)->add_message("not_found", "not_found_object"); return; } $obj = pmb_mysql_fetch_object($r); $this->libelle = $obj->libelle; $this->relance = $obj->relance; } public function get_form() { global $msg, $charset; global $lgstat_content_form; $content_form = $lgstat_content_form; $content_form = str_replace('!!id!!', $this->id_statut, $content_form); $interface_form = new interface_admin_form('lgstatform'); if(!$this->id_statut){ $interface_form->set_label($msg['acquisition_lgstat_add']); }else{ $interface_form->set_label($msg['acquisition_lgstat_mod']); } $content_form = str_replace('!!libelle!!', htmlentities($this->libelle, ENT_QUOTES, $charset), $content_form); $sel_relance = ""; $content_form = str_replace('!!sel_relance!!', $sel_relance, $content_form); $interface_form->set_object_id($this->id_statut) ->set_confirm_delete_msg($msg['confirm_suppr_de']." ".$this->libelle." ?") ->set_content_form($content_form) ->set_table_name('lignes_actes_statuts') ->set_field_focus('libelle'); return $interface_form->get_display(); } public function set_properties_from_form() { global $libelle, $relance; $this->libelle = stripslashes($libelle); $this->relance = stripslashes($relance); } public function get_query_if_exists() { $query = "select count(1) from lignes_actes_statuts where libelle = '".addslashes($this->libelle)."' "; if ($this->id_statut) $query.= "and id_statut != '".$this->id_statut."' "; return $query; } // enregistre un statut de ligne d'acte en base. public function save(){ if( $this->libelle == '' ) die("Erreur de création statut de ligne d'acte"); if ($this->id_statut) { $q = "update lignes_actes_statuts set libelle = '".addslashes($this->libelle)."', relance = '".addslashes($this->relance)."' where id_statut = '".$this->id_statut."' "; pmb_mysql_query($q); } else { $q = "insert into lignes_actes_statuts set libelle = '".addslashes($this->libelle)."', relance = '".addslashes($this->relance)."' "; pmb_mysql_query($q); $this->id_statut = pmb_mysql_insert_id(); } } //Retourne une liste des statuts de lignes d'actes (tableau) public static function getList($x='ARRAY_ALL') { global $dbh; $res = array(); $q = "select * from lignes_actes_statuts order by libelle "; switch ($x) { case 'QUERY' : return $q; case 'ARRAY_VALUES' : $r = pmb_mysql_query($q, $dbh); $res = array(); while ($row = pmb_mysql_fetch_object($r)){ $res[] = $row->id_statut; } break; case 'ARRAY_ALL': default : $r = pmb_mysql_query($q, $dbh); $res = array(); while ($row = pmb_mysql_fetch_object($r)){ $res[$row->id_statut] = array(); $res[$row->id_statut][0] = $row->libelle; $res[$row->id_statut][1] = $row->relance; } break; } return $res; } //Retourne un selecteur html avec la liste des statuts de lignes d'actes public static function getHtmlSelect($selected=array(), $sel_all='', $sel_attr=array()) { global $msg,$charset; $sel=''; $q = "select id_statut,libelle from lignes_actes_statuts order by libelle "; $r = pmb_mysql_query($q); $res = array(); if ($sel_all) { $res[0]=htmlentities($sel_all,ENT_QUOTES,$charset); } while ($row = pmb_mysql_fetch_object($r)){ $res[$row->id_statut] = $row->libelle; } $size=count($res); if (isset($sel_attr['size']) && $sel_attr['size']>$size) $sel_attr['size']=$size; if ($size) { $sel="