303 |
|
|
304 |
$sql = "UPDATE ".MAIN_DB_PREFIX."societe "; |
$sql = "UPDATE ".MAIN_DB_PREFIX."societe "; |
305 |
$sql .= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire |
$sql .= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire |
306 |
|
$sql .= ", datea = now()"; |
307 |
$sql .= ",address = '" . addslashes($this->adresse) ."'"; |
$sql .= ",address = '" . addslashes($this->adresse) ."'"; |
308 |
|
|
309 |
if ($this->cp) |
if ($this->cp) |
339 |
|
|
340 |
if ($this->creation_bit || $this->codeclient_modifiable) |
if ($this->creation_bit || $this->codeclient_modifiable) |
341 |
{ |
{ |
342 |
// Attention check_codeclient peut modifier le code |
// Attention check_codeclient peut modifier le code |
343 |
// suivant le module utilis |
// suivant le module utilis |
344 |
|
|
345 |
$this->check_codeclient(); |
$this->check_codeclient(); |
346 |
|
|
347 |
$sql .= ", code_client = ".($this->code_client?"'".$this->code_client."'":"null"); |
$sql .= ", code_client = ".($this->code_client?"'".$this->code_client."'":"null"); |
348 |
|
|
349 |
// Attention check_codecompta_client peut modifier le code |
// Attention check_codecompta_client peut modifier le code |
350 |
// suivant le module utilis |
// suivant le module utilis |
351 |
|
|
352 |
$this->check_codecompta_client(); |
$this->check_codecompta_client(); |
353 |
|
|
354 |
$sql .= ", code_compta = ".($this->code_compta?"'".$this->code_compta."'":"null"); |
$sql .= ", code_compta = ".($this->code_compta?"'".$this->code_compta."'":"null"); |
355 |
} |
} |
356 |
|
|
357 |
if ($this->creation_bit || $this->codefournisseur_modifiable) |
if ($this->creation_bit || $this->codefournisseur_modifiable) |
358 |
{ |
{ |
359 |
// Attention check_codefournisseur peut modifier le code |
// Attention check_codefournisseur peut modifier le code |
360 |
// suivant le module utilis |
// suivant le module utilis |
361 |
|
|
362 |
$this->check_codefournisseur(); |
$this->check_codefournisseur(); |
363 |
|
|
364 |
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->code_fournisseur."'":"null"); |
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->code_fournisseur."'":"null"); |
365 |
|
|
366 |
// Attention check_codecompta_fournisseur peut modifier le code |
// Attention check_codecompta_fournisseur peut modifier le code |
367 |
// suivant le module utilis |
// suivant le module utilis |
368 |
|
|
369 |
$this->check_codecompta_fournisseur(); |
$this->check_codecompta_fournisseur(); |
370 |
|
|
371 |
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->code_compta_fournisseur."'":"null"); |
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->code_compta_fournisseur."'":"null"); |
372 |
} |
} |
373 |
if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; |
if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; |
374 |
$sql .= " WHERE idp = '" . $id ."'"; |
$sql .= " WHERE idp = '" . $id ."'"; |
375 |
|
|
376 |
$resql=$this->db->query($sql); |
$resql=$this->db->query($sql); |
377 |
if ($resql) |
if ($resql) |
378 |
{ |
{ |
379 |
if ($call_trigger) |
if ($call_trigger) |
380 |
{ |
{ |
381 |
// Appel des triggers |
// Appel des triggers |
382 |
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); |
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); |
383 |
$interface=new Interfaces($this->db); |
$interface=new Interfaces($this->db); |
384 |
$result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf); |
$result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf); |
385 |
// Fin appel triggers |
// Fin appel triggers |
386 |
} |
} |
387 |
|
|
388 |
$result = 1; |
$result = 1; |
389 |
} |
} |
390 |
else |
else |
391 |
{ |
{ |
392 |
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
393 |
{ |
{ |
394 |
// Doublon |
// Doublon |
395 |
$this->error = $langs->trans("ErrorPrefixAlreadyExists",$this->prefix_comm); |
$this->error = $langs->trans("ErrorPrefixAlreadyExists",$this->prefix_comm); |
396 |
$result = -1; |
$result = -1; |
397 |
} |
} |
398 |
else |
else |
399 |
{ |
{ |
400 |
|
|
401 |
$this->error = $langs->trans("Error sql=$sql"); |
$this->error = $langs->trans("Error sql=$sql"); |
402 |
dolibarr_syslog("Societe::Update echec sql=$sql"); |
dolibarr_syslog("Societe::Update echec sql=$sql"); |
403 |
$result = -2; |
$result = -2; |
404 |
} |
} |
405 |
} |
} |
406 |
} |
} |
407 |
|
|
408 |
return $result; |
return $result; |