This commit is contained in:
parent
be5826057e
commit
ecb4128496
@ -854,7 +854,11 @@ class Categorie
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les catégories contenant le produit $id
|
* Return list of categories linked to element of type $type with id $typeid
|
||||||
|
* @param id Id of element
|
||||||
|
* @param type Type of link ('customer','fournisseur','societe'...)
|
||||||
|
* @param typeid Type id of link (0,1,2...)
|
||||||
|
* @return array List of category objects
|
||||||
*/
|
*/
|
||||||
function containing ($id,$type,$typeid)
|
function containing ($id,$type,$typeid)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -700,8 +700,35 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( $this->db->begin())
|
if ($this->db->begin())
|
||||||
{
|
{
|
||||||
|
// Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-third-party-deleting.html)
|
||||||
|
// Removing every "categorie" link with this company
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
||||||
|
|
||||||
|
$static_cat = new Categorie($this->db);
|
||||||
|
$toute_categs = array();
|
||||||
|
|
||||||
|
// Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
|
||||||
|
if ($this->client || $this->prospect)
|
||||||
|
{
|
||||||
|
$toute_categs ['societe'] = $static_cat->containing($this->id,'societe',2);
|
||||||
|
}
|
||||||
|
if ($this->fournisseur)
|
||||||
|
{
|
||||||
|
$toute_categs ['fournisseur'] = $static_cat->containing($this->id,'fournisseur',1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove each "Categorie"
|
||||||
|
foreach ($toute_categs as $type => $categs_type)
|
||||||
|
{
|
||||||
|
foreach ($categs_type as $cat)
|
||||||
|
{
|
||||||
|
$cat->del_type($this, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove contacts
|
||||||
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
|
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
|
||||||
$sql.= " WHERE fk_soc = " . $id;
|
$sql.= " WHERE fk_soc = " . $id;
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user