Ajout check du nom de la societe

This commit is contained in:
Rodolphe Quiedeville 2003-11-25 13:24:15 +00:00
parent cd6732d9fc
commit 27c503e1e6

View File

@ -38,7 +38,8 @@ class Societe {
var $fournisseur; var $fournisseur;
Function Societe($DB, $id=0) { Function Societe($DB, $id=0)
{
global $config; global $config;
$this->db = $DB; $this->db = $DB;
@ -52,10 +53,8 @@ class Societe {
* *
* *
*/ */
Function create() { Function create()
{
print $this->url;
$sql = "INSERT INTO llx_societe (nom, datec, datea, client) "; $sql = "INSERT INTO llx_societe (nom, datec, datea, client) ";
$sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client);"; $sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client);";
@ -73,26 +72,30 @@ class Societe {
* *
*/ */
Function update($id) Function update($id)
{ {
if (strlen(trim($this->nom)) == 0)
{
$this->nom = "VALEUR MANQUANTE";
}
$sql = "UPDATE llx_societe "; $sql = "UPDATE llx_societe ";
$sql .= " SET nom = '" . trim($this->nom) ."'"; $sql .= " SET nom = '" . trim($this->nom) ."'";
$sql .= ",address = '" . trim($this->adresse) ."'"; $sql .= ",address = '" . trim($this->adresse) ."'";
$sql .= ",cp = '" . trim($this->cp) ."'"; $sql .= ",cp = '" . trim($this->cp) ."'";
$sql .= ",ville = '" . trim($this->ville) ."'"; $sql .= ",ville = '" . trim($this->ville) ."'";
$sql .= ",tel = '" . trim($this->tel) ."'"; $sql .= ",tel = '" . trim($this->tel) ."'";
$sql .= ",fax = '" . trim($this->fax) ."'"; $sql .= ",fax = '" . trim($this->fax) ."'";
$sql .= ",url = '" . trim($this->url) ."'"; $sql .= ",url = '" . trim($this->url) ."'";
$sql .= ",siren = '" . trim($this->siren) ."'"; $sql .= ",siren = '" . trim($this->siren) ."'";
$sql .= ",client = " . $this->client ; $sql .= ",client = " . $this->client ;
$sql .= ",fournisseur = " . $this->fournisseur ; $sql .= ",fournisseur = " . $this->fournisseur ;
$sql .= " WHERE idp = " . $id .";"; $sql .= " WHERE idp = " . $id .";";
if (! $this->db->query($sql)) if (! $this->db->query($sql))
{ {
print $this->db->error(); print $this->db->error();
} }
} }
/* /*
* Suppression d'une societe. * Suppression d'une societe.