diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 52af47a83a5..04ba162cb9e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3119,7 +3119,6 @@ class Commande extends CommonOrder // End call triggers } - //TODO: Check for error after each action. If one failed we rollback, don't waste time to do action if previous fail if (! $error) { // Delete order details @@ -3129,23 +3128,24 @@ class Commande extends CommonOrder $error++; $this->errors[]=$this->db->lasterror(); } + } - // Delete order - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; - if (! $this->db->query($sql) ) - { - $error++; - $this->errors[]=$this->db->lasterror(); - } - + if (! $error) + { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; + } + if (! $error) + { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) $error++; + } + if (! $error) + { // Remove extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { @@ -3156,8 +3156,22 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } + } - // On efface le repertoire de pdf provisoire + if (! $error) + { + // Delete object + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; + if (! $this->db->query($sql) ) + { + $error++; + $this->errors[]=$this->db->lasterror(); + } + } + + if (! $error) + { + // Remove directory with files $comref = dol_sanitizeFileName($this->ref); if ($conf->commande->dir_output && !empty($this->ref)) { @@ -3183,8 +3197,6 @@ class Commande extends CommonOrder } } } - - } if (! $error) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 986d48b37e1..edf1cf0e721 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3650,7 +3650,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $return.= "\n"; $return.= ''; - if ($picto) $return.= ''; + if ($picto) $return.= ''; $return.= ''; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 25cf644db0f..237d09570d1 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -840,85 +840,96 @@ class Fichinter extends CommonObject $this->db->begin(); + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('FICHINTER_DELETE',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers + } + // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if (! $error) + { + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) + if (! $error) { - $this->error='ErrorFailToDeleteLinkedContact'; - $error++; + $res = $this->delete_linked_contact(); + if ($res < 0) + { + $this->error='ErrorFailToDeleteLinkedContact'; + $error++; + } } - if ($error) + if (! $error) { - $this->db->rollback(); - return -1; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet"; + $sql.= " WHERE fk_fichinter = ".$this->id; + + $resql = $this->db->query($sql); + if (! $resql) $error++; } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet"; - $sql.= " WHERE fk_fichinter = ".$this->id; - - dol_syslog("Fichinter::delete", LOG_DEBUG); - if ( $this->db->query($sql) ) + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { + // Remove extrafields + $res = $this->deleteExtraFields(); + if ($res < 0) $error++; + } + + if (! $error) + { + // Delete object $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND entity = ".$conf->entity; dol_syslog("Fichinter::delete", LOG_DEBUG); - if ( $this->db->query($sql) ) + $resql = $this->db->query($sql); + if (! $resql) $error++; + } + + if (! $error) + { + // Remove directory with files + $fichinterref = dol_sanitizeFileName($this->ref); + if ($conf->ficheinter->dir_output) { - - // Remove directory with files - $fichinterref = dol_sanitizeFileName($this->ref); - if ($conf->ficheinter->dir_output) + $dir = $conf->ficheinter->dir_output . "/" . $fichinterref ; + $file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; + if (file_exists($file)) { - $dir = $conf->ficheinter->dir_output . "/" . $fichinterref ; - $file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; - if (file_exists($file)) - { - dol_delete_preview($this); + dol_delete_preview($this); - if (! dol_delete_file($file,0,0,0,$this)) // For triggers - { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - return 0; - } - } - if (file_exists($dir)) + if (! dol_delete_file($file,0,0,0,$this)) // For triggers { - if (! dol_delete_dir_recursive($dir)) - { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - return 0; - } + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + return 0; } } - - if (! $notrigger) + if (file_exists($dir)) { - // Call trigger - $result=$this->call_trigger('FICHINTER_DELETE',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + if (! dol_delete_dir_recursive($dir)) + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + return 0; + } } + } + } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } + if (! $error) + { + $this->db->commit(); + return 1; } else { - $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; }
'.img_picto('',$picto, 'class="valignmiddle" id="pictotitle"', $pictoisfullpath).''.img_picto('',$picto, 'class="valignmiddle widthpictotitle" id="pictotitle"', $pictoisfullpath).''; $return.= '
'.$titre.'
'; $return.= '