From 923c4d475489391363980ef0b3abac32874ce1f1 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 30 Apr 2002 11:30:19 +0000 Subject: [PATCH] Update attribute_prefix action --- htdocs/societe.class.php3 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/htdocs/societe.class.php3 b/htdocs/societe.class.php3 index 9289e96b17f..09776564068 100644 --- a/htdocs/societe.class.php3 +++ b/htdocs/societe.class.php3 @@ -127,6 +127,45 @@ class Societe { * * */ + + Function attribute_prefix() { + $sql = "SELECT nom FROM societe WHERE idp = $this->id"; + if ( $this->db->query( $sql) ) { + if ( $this->db->num_rows() ) { + $nom = $this->db->result(0,0); + $this->db->free(); + + $prefix = strtoupper(substr($nom, 0, 2)); + + $sql = "SELECT count(*) FROM societe WHERE prefix_comm = '$prefix'"; + if ( $this->db->query( $sql) ) { + if ( $this->db->result(0, 0) ) { + $this->db->free(); + } else { + $this->db->free(); + $sql = "UPDATE societe set prefix_comm='$prefix' WHERE idp=$this->id"; + + if ( $this->db->query( $sql) ) { + + } else { + print $this->db->error(); + } + } + } else { + print $this->db->error(); + } + } + } else { + print $this->db->error(); + } + return $prefix; + } + /* + * + * + * + */ + Function get_nom($id) { $sql = "SELECT nom FROM societe WHERE idp=$id;";