Update attribute_prefix action
This commit is contained in:
parent
dc3607d385
commit
923c4d4754
@ -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) {
|
Function get_nom($id) {
|
||||||
|
|
||||||
$sql = "SELECT nom FROM societe WHERE idp=$id;";
|
$sql = "SELECT nom FROM societe WHERE idp=$id;";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user