2
0
forked from Wavyzz/dolibarr

Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/accountancy/bookkeeping/balance.php
	htdocs/core/class/html.formmail.class.php
	htdocs/fourn/class/fournisseur.commande.class.php
	htdocs/fourn/class/fournisseur.facture.class.php
	htdocs/langs/en_US/other.lang
	htdocs/product/class/product.class.php
	htdocs/supplier_proposal/class/supplier_proposal.class.php
This commit is contained in:
Laurent Destailleur
2020-09-12 04:42:59 +02:00
23 changed files with 150 additions and 53 deletions

View File

@@ -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>
@@ -8415,4 +8415,49 @@ abstract class CommonObject
$this->db->commit();
return 1;
}
/**
* Delete related files of object in database
*
* @return bool
*/
public function deleteEcmFiles()
{
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;
}
}