Fix the trigger on delete thirdparty was not called

This commit is contained in:
Laurent Destailleur 2015-06-07 03:41:12 +02:00
parent 7e169c0801
commit 37cadaf4bf
2 changed files with 15 additions and 17 deletions

View File

@ -1215,7 +1215,7 @@ class Categorie extends CommonObject
}
/**
* Return list of categories (id or instances) linked to element of id $id and type $type
* Return list of categories (object instances or labels) linked to element of id $id and type $type
* Should be named getListOfCategForObject
*
* @param int $id Id of element
@ -1228,20 +1228,15 @@ class Categorie extends CommonObject
*/
function containing($id,$type,$mode='object')
{
// Deprecation warning
if (is_numeric($type)) {
dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING);
}
$cats = array();
// For backward compatibility
if (is_numeric( $type )) {
if (is_numeric($type))
{
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
// We want to reverse lookup
$map_type = array_flip( $this->MAP_ID );
$map_type = array_flip($this->MAP_ID);
$type = $map_type[$type];
dol_syslog( get_class( $this ) . "::containing(): numeric types are deprecated, please use string instead",
LOG_WARNING );
}
$sql = "SELECT ct.fk_categorie, c.label";
@ -1249,7 +1244,6 @@ class Categorie extends CommonObject
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . $id . " AND c.type = " . $this->MAP_ID[$type];
$sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
dol_syslog(get_class($this).'::containing', LOG_DEBUG);
$res = $this->db->query($sql);
if ($res)
{

View File

@ -317,6 +317,7 @@ class Societe extends CommonObject
* @var string
*/
var $note_public;
//! code statut prospect
var $stcomm_id;
var $statut_commercial;
@ -1303,11 +1304,13 @@ class Societe extends CommonObject
* @param int $id Id of third party to delete
* @param User $user User who ask to delete thirparty
* @param int $call_trigger 0=No, 1=yes
* @return int <0 if KO, 0 if nothing done, >0 if OK
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
function delete($id, $user='', $call_trigger=1)
function delete($id, User $fuser=null, $call_trigger=1)
{
global $langs, $conf;
global $langs, $conf, $user;
if (empty($fuser)) $fuser=$user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -1323,10 +1326,10 @@ class Societe extends CommonObject
$this->db->begin();
// User is mandatory for trigger call
if ($user && $call_trigger)
if ($call_trigger)
{
// Call trigger
$result=$this->call_trigger('COMPANY_DELETE',$user);
$result=$this->call_trigger('COMPANY_DELETE',$fuser);
if ($result < 0) $error++;
// End call triggers
}
@ -1451,7 +1454,8 @@ class Societe extends CommonObject
return 1;
}
else
{
{
dol_syslog($this->error, LOG_ERR);
$this->db->rollback();
return -1;
}