Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
1022c73c24
@ -138,6 +138,8 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
//! Contains detail of stock of product into each warehouse
|
//! Contains detail of stock of product into each warehouse
|
||||||
var $stock_warehouse=array();
|
var $stock_warehouse=array();
|
||||||
|
|
||||||
|
var $oldcopy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,7 +324,7 @@ class Product extends CommonObject
|
|||||||
$result = $this->_log_price($user);
|
$result = $this->_log_price($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ( $this->update($id, $user, true) > 0)
|
if ($this->update($id, $user, true) > 0)
|
||||||
{
|
{
|
||||||
if ($this->catid > 0)
|
if ($this->catid > 0)
|
||||||
{
|
{
|
||||||
@ -403,6 +405,8 @@ class Product extends CommonObject
|
|||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
// Verification parametres
|
// Verification parametres
|
||||||
if (! $this->libelle) $this->libelle = 'MISSING LABEL';
|
if (! $this->libelle) $this->libelle = 'MISSING LABEL';
|
||||||
@ -504,8 +508,36 @@ class Product extends CommonObject
|
|||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
|
||||||
|
{
|
||||||
|
// We remove directory
|
||||||
|
if ($conf->product->dir_output)
|
||||||
|
{
|
||||||
|
$olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
|
||||||
|
$newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref);
|
||||||
|
if (file_exists($olddir))
|
||||||
|
{
|
||||||
|
$res=@dol_move($olddir, $newdir);
|
||||||
|
if (! $res)
|
||||||
|
{
|
||||||
|
$this->error='ErrorFailToMoveDir';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -$error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -572,22 +604,6 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove this. It can already be addressed by previous triggers
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
// Actions on extra fields (by external module or standard code)
|
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
|
||||||
$hookmanager=new HookManager($this->db);
|
|
||||||
$hookmanager->initHooks(array('productdao'));
|
|
||||||
$parameters=array(); $action='delete';
|
|
||||||
$reshook=$hookmanager->executeHooks('deleteProduct',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
|
||||||
if (! empty($hookmanager->error))
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$this->error=$hookmanager->error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete product
|
// Delete product
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -602,16 +618,35 @@ class Product extends CommonObject
|
|||||||
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
|
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// We remove directory
|
||||||
|
$ref = dol_sanitizeFileName($this->ref);
|
||||||
|
if ($conf->product->dir_output)
|
||||||
|
{
|
||||||
|
$dir = $conf->product->dir_output . "/" . $ref;
|
||||||
|
if (file_exists($dir))
|
||||||
|
{
|
||||||
|
$res=@dol_delete_dir_recursive($dir);
|
||||||
|
if (! $res)
|
||||||
|
{
|
||||||
|
$this->error='ErrorFailToDeleteDir';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->commit();
|
||||||
return -$error;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->rollback();
|
||||||
return 1;
|
return -$error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -250,6 +250,8 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
if ($object->fetch($id,$ref))
|
if ($object->fetch($id,$ref))
|
||||||
{
|
{
|
||||||
|
$object->oldcopy=dol_clone($object);
|
||||||
|
|
||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
$object->libelle = $_POST["libelle"];
|
$object->libelle = $_POST["libelle"];
|
||||||
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
|
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
|
||||||
|
|||||||
@ -138,6 +138,8 @@ class Societe extends CommonObject
|
|||||||
var $logo;
|
var $logo;
|
||||||
var $logo_small;
|
var $logo_small;
|
||||||
var $logo_mini;
|
var $logo_mini;
|
||||||
|
|
||||||
|
var $oldcopy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user