Fix: works on edit in place with external modules

This commit is contained in:
Regis Houssin
2012-02-07 16:51:38 +01:00
parent b62d16e2ac
commit ff59631e11
3 changed files with 39 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -134,6 +134,14 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if (! $error) if (! $error)
{ {
if (! is_object($object)) $object = new GenericObject($db); if (! is_object($object)) $object = new GenericObject($db);
// Specific for add_object_linked()
// TODO add a function for variable treatment
$object->ext_fk_element = $newvalue;
$object->ext_element = $ext_element;
$object->fk_element = $fk_element;
$object->element = $element;
$ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
if ($ret > 0) if ($ret > 0)
{ {

View File

@@ -1654,6 +1654,30 @@ abstract class CommonObject
} }
} }
/**
* Delete all links between an object $this
*
* @return int >0 if OK, <0 if KO
*/
function deleteObjectLinked()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::deleteObjectLinked error=".$this->error, LOG_ERR);
return -1;
}
}
/** /**
* Set statut of an object * Set statut of an object
* *
@@ -2069,19 +2093,19 @@ abstract class CommonObject
if ($objecttype == 'facture') { if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element; $tplpath = 'compta/'.$element;
} }
if ($objecttype == 'propal') { else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element; $tplpath = 'comm/'.$element;
} }
if ($objecttype == 'shipping') { else if ($objecttype == 'shipping') {
$tplpath = 'expedition'; $tplpath = 'expedition';
} }
if ($objecttype == 'delivery') { else if ($objecttype == 'delivery') {
$tplpath = 'livraison'; $tplpath = 'livraison';
} }
if ($objecttype == 'invoice_supplier') { else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture'; $tplpath = 'fourn/facture';
} }
if ($objecttype == 'order_supplier') { else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande'; $tplpath = 'fourn/commande';
} }