Fix: Error management
This commit is contained in:
parent
b3641fbc03
commit
fcd89b7ca2
@ -199,6 +199,7 @@ class Societe extends CommonObject
|
|||||||
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1);
|
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1);
|
||||||
|
|
||||||
// Check more parameters
|
// Check more parameters
|
||||||
|
// If error, this->errors[] is filled
|
||||||
$result = $this->verify();
|
$result = $this->verify();
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -250,7 +251,7 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog("Societe::Create echec update ".$this->error);
|
dol_syslog("Societe::Create echec update ".$this->error, LOG_ERR);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -261,22 +262,24 @@ class Societe extends CommonObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
|
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
|
||||||
|
$result=-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dol_syslog("Societe::Create echec insert sql=".$sql);
|
dol_syslog("Societe::Create fails insert sql=".$sql, LOG_ERR);
|
||||||
|
$result=-2;
|
||||||
}
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
dol_syslog("Societe::Create echec verify ".join(',',$this->errors));
|
dol_syslog("Societe::Create fails verify ".join(',',$this->errors), LOG_WARNING);
|
||||||
return -1;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,6 +435,8 @@ class Societe extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
// Check name is required and codes are ok or unique.
|
// Check name is required and codes are ok or unique.
|
||||||
// If error, this->errors[] is filled
|
// If error, this->errors[] is filled
|
||||||
$result = $this->verify();
|
$result = $this->verify();
|
||||||
@ -529,7 +534,9 @@ class Societe extends CommonObject
|
|||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = 1;
|
dol_syslog("Societe::Update success");
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -543,14 +550,19 @@ class Societe extends CommonObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->error = $langs->trans("Error sql=".$sql);
|
$this->error = $langs->trans("Error sql=".$sql);
|
||||||
dol_syslog("Societe::Update echec sql=".$sql);
|
dol_syslog("Societe::Update fails update sql=".$sql, LOG_ERR);
|
||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
}
|
$this->db->rollback();
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
dol_syslog("Societe::Update fails verify ".join(',',$this->errors), LOG_WARNING);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -70,7 +70,7 @@ else
|
|||||||
$result = restrictedArea($user, 'societe', $socid);
|
$result = restrictedArea($user, 'societe', $socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$error=$nuser->error; $errors=$nuser->errors;
|
$error=0; $errors=array();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -298,8 +298,7 @@ else
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$soc->id = $socid;
|
$soc->id = $socid;
|
||||||
|
$error = $langs->trans($soc->error); $errors = $soc->errors;
|
||||||
$error = $soc->error;
|
|
||||||
$action= "edit";
|
$action= "edit";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +319,7 @@ else
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$error=$langs->trans($soc->error);
|
$error=$langs->trans($soc->error); $errors = $soc->errors;
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -969,7 +968,7 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_htmloutput_errors($error,errors);
|
dol_htmloutput_errors($error,$errors);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user