Skip to content
Snippets Groups Projects
Commit 7ac9943b authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Better error management

parent 208224fc
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ class Fichinter extends CommonObject ...@@ -70,6 +70,7 @@ class Fichinter extends CommonObject
$this->socid = $socid; $this->socid = $socid;
$this->products = array(); $this->products = array();
$this->fk_project = 0; $this->fk_project = 0;
$this->statut = 0;
// List of language codes for status // List of language codes for status
$this->statuts[0]='Draft'; $this->statuts[0]='Draft';
...@@ -89,6 +90,7 @@ class Fichinter extends CommonObject ...@@ -89,6 +90,7 @@ class Fichinter extends CommonObject
dol_syslog("Fichinter.class::create ref=".$this->ref); dol_syslog("Fichinter.class::create ref=".$this->ref);
// Check parameters
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) { $this->duree = 0; }
if ($this->socid <= 0) if ($this->socid <= 0)
{ {
...@@ -96,11 +98,6 @@ class Fichinter extends CommonObject ...@@ -96,11 +98,6 @@ class Fichinter extends CommonObject
dol_syslog("Fichinter::create ".$this->error,LOG_ERR); dol_syslog("Fichinter::create ".$this->error,LOG_ERR);
return -1; return -1;
} }
$now=dol_now();
$this->db->begin();
// on verifie si la ref n'est pas utilisee // on verifie si la ref n'est pas utilisee
$soc = new Societe($this->db); $soc = new Societe($this->db);
$result=$soc->fetch($this->socid); $result=$soc->fetch($this->socid);
...@@ -120,6 +117,10 @@ class Fichinter extends CommonObject ...@@ -120,6 +117,10 @@ class Fichinter extends CommonObject
return -2; return -2;
} }
$now=dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."fichinter (";
$sql.= "fk_soc"; $sql.= "fk_soc";
$sql.= ", datec"; $sql.= ", datec";
...@@ -129,6 +130,7 @@ class Fichinter extends CommonObject ...@@ -129,6 +130,7 @@ class Fichinter extends CommonObject
$sql.= ", description"; $sql.= ", description";
$sql.= ", model_pdf"; $sql.= ", model_pdf";
$sql.= ", fk_projet"; $sql.= ", fk_projet";
$sql.= ", fk_statut";
$sql.= ") "; $sql.= ") ";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= $this->socid; $sql.= $this->socid;
...@@ -136,9 +138,10 @@ class Fichinter extends CommonObject ...@@ -136,9 +138,10 @@ class Fichinter extends CommonObject
$sql.= ", '".$this->ref."'"; $sql.= ", '".$this->ref."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", ".$this->author; $sql.= ", ".$this->author;
$sql.= ", '".addslashes($this->description)."'"; $sql.= ", ".($this->description?"'".addslashes($this->description)."'":"null");
$sql.= ", '".$this->modelpdf."'"; $sql.= ", '".$this->modelpdf."'";
$sql.= ", ".($this->fk_project ? $this->fk_project : 0); $sql.= ", ".($this->fk_project ? $this->fk_project : 0);
$sql.= ", ".$this->statut;
$sql.= ")"; $sql.= ")";
dol_syslog("Fichinter::create sql=".$sql); dol_syslog("Fichinter::create sql=".$sql);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment