Update attribute_prefix action

This commit is contained in:
Rodolphe Quiedeville 2002-04-30 11:30:19 +00:00
parent dc3607d385
commit 923c4d4754

View File

@ -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;";