diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5ec65444746..2cd27d6d688 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2013-2015 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García @@ -831,6 +831,8 @@ if (empty($reshook)) // Auto calculation of date due if not filled by user if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + $object->fetch_thirdparty(); + // If creation from another object of another module if (! $error && $_POST['origin'] && $_POST['originid']) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c762b7f65e7..6b1d5e0a07f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2017 Marcos García * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2019 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -707,6 +708,27 @@ class Project extends CommonObject $ret = $this->deleteTasks($user); if ($ret < 0) $error++; + + // Delete all child tables + if (! $error) { + $elements = array('categorie_project'); // elements to delete. TODO Make goodway to delete + foreach($elements as $table) + { + if (! $error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; + $sql.= " WHERE fk_project = ".$this->id; + + $result = $this->db->query($sql); + if (! $result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + } + } + + + // Delete project if (! $error) {