mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX: #14474 Error when deleting
This commit is contained in:
parent
162da37f1a
commit
bb92e64e43
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2019 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2017 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
|
|
@ -1063,7 +1063,7 @@ class Propal extends CommonObject
|
|||
$ret = $this->add_object_linked();
|
||||
if (! $ret) dol_print_error($this->db);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Insertion du detail des produits dans la base
|
||||
* Insert products detail in database
|
||||
|
|
@ -2900,6 +2900,12 @@ class Propal extends CommonObject
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We remove directory
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
|
|
@ -3327,6 +3327,11 @@ class Commande extends CommonOrder
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
// Remove directory with files
|
||||
$comref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->commande->dir_output && !empty($this->ref))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
|
|
@ -2019,6 +2019,12 @@ class Facture extends CommonInvoice
|
|||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// On efface le repertoire de pdf provisoire
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->facture->dir_output && !empty($this->ref))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2019 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
|
|
@ -7734,4 +7734,47 @@ abstract class CommonObject
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete related files of object in database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_ecmfiles(){
|
||||
global $conf;
|
||||
$this->db->begin();
|
||||
|
||||
switch ($this->element){
|
||||
case 'propal':
|
||||
$element = 'propale';
|
||||
break;
|
||||
case 'product':
|
||||
$element = 'produit';
|
||||
break;
|
||||
case 'order_supplier':
|
||||
$element ='fournisseur/commande';
|
||||
break;
|
||||
case 'invoice_supplier':
|
||||
$element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier');
|
||||
break;
|
||||
case 'shipping':
|
||||
$element = 'expedition/sending';
|
||||
break;
|
||||
default:
|
||||
$element = $this->element;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
|
||||
$sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
|
||||
$sql.= " AND filepath = '".$element."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity;
|
||||
|
||||
if (!$this->db->query($sql)) {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
|
|
@ -1310,6 +1310,12 @@ class Expedition extends CommonObject
|
|||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We delete PDFs
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if (! empty($conf->expedition->dir_output))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
|
|
@ -1003,6 +1003,12 @@ class Fichinter extends CommonObject
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove directory with files
|
||||
$fichinterref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->ficheinter->dir_output)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2018 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
|
|
@ -1979,6 +1979,12 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We remove directory
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->fournisseur->commande->dir_output)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
* Copyright (C) 2005 Marc Barilley <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||
|
|
@ -1157,6 +1157,12 @@ class FactureFournisseur extends CommonInvoice
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We remove directory
|
||||
if ($conf->fournisseur->facture->dir_output)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2018 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
|
|
@ -2065,6 +2065,12 @@ class SupplierProposal extends CommonObject
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
// On delete ecm_files database info
|
||||
if (!$this->delete_ecmfiles()) {
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We remove directory
|
||||
$ref = dol_sanitizeFileName($this->ref);
|
||||
if ($conf->supplier_proposal->dir_output && !empty($this->ref))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user