forked from Wavyzz/dolibarr
Fix: Error management
This commit is contained in:
@@ -556,10 +556,10 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create commercial proposal
|
* Create commercial proposal into database
|
||||||
* \param user User that create
|
* this->ref can be set or empty. If empty, we will use "(PROVid)"
|
||||||
* \return int <0 if KO, >=0 if OK
|
* @param user User that create
|
||||||
* \remarks this->ref can be set or empty. If empty, we will use "(PROV)"
|
* @return int <0 if KO, >=0 if OK
|
||||||
*/
|
*/
|
||||||
function create($user='', $notrigger=0)
|
function create($user='', $notrigger=0)
|
||||||
{
|
{
|
||||||
@@ -578,7 +578,7 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->error="Failed to fetch company";
|
$this->error="Failed to fetch company";
|
||||||
dol_syslog("Propal::create ".$this->error, LOG_ERR);
|
dol_syslog("Propal::create ".$this->error, LOG_ERR);
|
||||||
return -2;
|
return -3;
|
||||||
}
|
}
|
||||||
if (! empty($this->ref))
|
if (! empty($this->ref))
|
||||||
{
|
{
|
||||||
@@ -590,7 +590,7 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
$this->fetch_thirdparty();
|
$this->fetch_thirdparty();
|
||||||
|
|
||||||
// Insertion dans la base
|
// Insert into database
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (";
|
||||||
$sql.= "fk_soc";
|
$sql.= "fk_soc";
|
||||||
$sql.= ", price";
|
$sql.= ", price";
|
||||||
@@ -654,6 +654,8 @@ class Propal extends CommonObject
|
|||||||
/*
|
/*
|
||||||
* Insertion du detail des produits dans la base
|
* Insertion du detail des produits dans la base
|
||||||
*/
|
*/
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
|
for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
|
||||||
{
|
{
|
||||||
$resql = $this->addline(
|
$resql = $this->addline(
|
||||||
@@ -676,21 +678,23 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
if ($resql < 0)
|
if ($resql < 0)
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
$this->error=$this->db->error;
|
$this->error=$this->db->error;
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add linked object
|
// Add linked object
|
||||||
if ($this->origin && $this->origin_id)
|
if (! $error && $this->origin && $this->origin_id)
|
||||||
{
|
{
|
||||||
$ret = $this->add_object_linked();
|
$ret = $this->add_object_linked();
|
||||||
if (! $ret) dol_print_error($this->db);
|
if (! $ret) dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affectation au projet
|
// Affectation au projet
|
||||||
if ($resql && $this->fk_project)
|
if (! $error && $this->fk_project)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||||
$sql.= " SET fk_projet=".$this->fk_project;
|
$sql.= " SET fk_projet=".$this->fk_project;
|
||||||
@@ -701,7 +705,7 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Affectation de l'adresse de livraison
|
// Affectation de l'adresse de livraison
|
||||||
if ($resql && $this->fk_delivery_address)
|
if (! $error && $this->fk_delivery_address)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||||
$sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address;
|
$sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address;
|
||||||
@@ -711,7 +715,7 @@ class Propal extends CommonObject
|
|||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($resql)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Mise a jour infos denormalisees
|
// Mise a jour infos denormalisees
|
||||||
$resql=$this->update_price();
|
$resql=$this->update_price();
|
||||||
@@ -726,9 +730,22 @@ class Propal extends CommonObject
|
|||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
dol_syslog("Propal::ass::Create done id=".$this->id);
|
dol_syslog("Propal::Create done id=".$this->id);
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -739,8 +756,6 @@ class Propal extends CommonObject
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
@@ -748,10 +763,6 @@ class Propal extends CommonObject
|
|||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->commit();
|
|
||||||
dol_syslog("Propal::Create done id=".$this->id, LOG_ERR);
|
|
||||||
return $this->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user