diff --git a/htdocs/soc.php3 b/htdocs/soc.php3 index 40de61d1b8b..54084308d65 100644 --- a/htdocs/soc.php3 +++ b/htdocs/soc.php3 @@ -25,31 +25,29 @@ require("pre.inc.php3"); llxHeader(); $db = new Db(); -if ($sortorder == "") { - $sortfield="lower(s.nom)"; - $sortorder="ASC"; -} -if ($page == -1) { $page = 0 ; } -$limit = 26; -$offset = $limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; -if ($action == 'add') { +if ($action == 'add') +{ $soc = new Societe($db); $soc->nom = $nom; - $soc->tel = $tel; - $soc->fax = $fax; - $soc->url = $url; + $soc->adresse = $adresse; + $soc->cp = $cp; + $soc->ville = $ville; - $soc->client = 1; + $soc->tel = $tel; + $soc->fax = $fax; + $soc->url = $url; + $soc->siren = $siren; + $soc->client = 1; + $soc->fournisseur = $fournisseur; $socid = $soc->create(); } -if ($action == 'update') { +if ($action == 'update') +{ $soc = new Societe($db); $soc->nom = $nom; @@ -73,10 +71,12 @@ if ($action == 'update') { * */ -if ($action == 'create') { +if ($action == 'create') +{ print '
$docdir
"; - print 'Documents'; - } else { - - mkdir ("$docdir", 2775); - if (file_exists ($docdir)) { + if (file_exists ($docdir)) + { + print "
$docdir
"; print 'Documents'; } - } + else + { + + mkdir ("$docdir", 2775); + if (file_exists ($docdir)) + { + print 'Documents'; + } + } } $db->close(); diff --git a/htdocs/societe.class.php3 b/htdocs/societe.class.php3 index 97c575a8c44..90ee7a0bfc3 100644 --- a/htdocs/societe.class.php3 +++ b/htdocs/societe.class.php3 @@ -40,7 +40,7 @@ class Societe { $this->db = $DB; $this->id = $id; - + $this->fournisseur = 0; return 1; } /* @@ -50,8 +50,10 @@ class Societe { */ Function create() { + print $this->url; + $sql = "INSERT INTO societe (nom, datec, datea, client) "; - $sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client)"; + $sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client);"; if ($this->db->query($sql) ) { $id = $this->db->last_insert_id(); @@ -71,9 +73,10 @@ class Societe { * Force au statut de fournisseur si ce n'est pas un client * sinon l'entreprise disparait de toutes les listes */ - if ($this->client == 0 ) { - $this->fournisseur = 1; - } + if ($this->client == 0 ) + { + $this->fournisseur = 1; + } $sql = "UPDATE societe "; $sql .= " SET nom = '" . trim($this->nom) ."'"; @@ -86,9 +89,12 @@ class Societe { $sql .= ",siren = '" . trim($this->siren) ."'"; $sql .= ",client = " . $this->client ; $sql .= ",fournisseur = " . $this->fournisseur ; - $sql .= " WHERE idp = " . $id; + $sql .= " WHERE idp = " . $id .";"; - $this->db->query($sql); + if (! $this->db->query($sql)) + { + print $this->db->error(); + } } /* * @@ -141,59 +147,77 @@ 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(); + 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)); - $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(); - } + $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(); - } - } - } else { - print $this->db->error(); + else + { + print $this->db->error(); + } + return $prefix; } - return $prefix; - } /* * * * */ - Function get_nom($id) { - - $sql = "SELECT nom FROM societe WHERE idp=$id;"; - - $result = $this->db->query($sql); - - if ($result) { - if ($this->db->num_rows()) { - $obj = $this->db->fetch_object($result , 0); - - $this->nom = $obj->nom; + Function get_nom($id) + { + $sql = "SELECT nom FROM societe WHERE idp=$id;"; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object($result , 0); + + $this->nom = $obj->nom; + + } + $this->db->free(); } - $this->db->free(); - } }