Fix: [ bug 1794 ] - Error when cloning Proposal gives error in a malformed page
This commit is contained in:
parent
001f1b4c31
commit
e80f29c271
@ -112,20 +112,20 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Action clone object
|
// Action clone object
|
||||||
if ($action == 'confirm_clone' && $confirm == 'yes') {
|
if ($action == 'confirm_clone' && $confirm == 'yes') {
|
||||||
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) {
|
// if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) {
|
||||||
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
|
// setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
|
||||||
} else {
|
// } else {
|
||||||
if ($object->id > 0) {
|
if ($object->id > 0) {
|
||||||
$result = $object->createFromClone($socid);
|
$result = $object->createFromClone($socid);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
|
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($object->error, 'errors');
|
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete proposal
|
// Delete proposal
|
||||||
|
|||||||
@ -956,35 +956,35 @@ class Propal extends CommonObject
|
|||||||
foreach($this->lines as $line)
|
foreach($this->lines as $line)
|
||||||
$line->fetch_optionals($line->rowid);
|
$line->fetch_optionals($line->rowid);
|
||||||
|
|
||||||
// Load source object
|
// Load dest object
|
||||||
$objFrom = dol_clone($this);
|
$clonedObj = clone $this;
|
||||||
|
|
||||||
$objsoc=new Societe($this->db);
|
$objsoc=new Societe($this->db);
|
||||||
|
|
||||||
// Change socid if needed
|
// Change socid if needed
|
||||||
if (! empty($socid) && $socid != $this->socid)
|
if (! empty($socid) && $socid != $clonedObj->socid)
|
||||||
{
|
{
|
||||||
if ($objsoc->fetch($socid) > 0)
|
if ($objsoc->fetch($socid) > 0)
|
||||||
{
|
{
|
||||||
$this->socid = $objsoc->id;
|
$clonedObj->socid = $objsoc->id;
|
||||||
$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
|
$clonedObj->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
|
||||||
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
|
$clonedObj->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
|
||||||
$this->fk_project = '';
|
$clonedObj->fk_project = '';
|
||||||
$this->fk_delivery_address = '';
|
$clonedObj->fk_delivery_address = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset ref_client
|
// reset ref_client
|
||||||
$this->ref_client = '';
|
$clonedObj->ref_client = '';
|
||||||
|
|
||||||
// TODO Change product price if multi-prices
|
// TODO Change product price if multi-prices
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$objsoc->fetch($this->socid);
|
$objsoc->fetch($clonedObj->socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id=0;
|
$clonedObj->id=0;
|
||||||
$this->statut=0;
|
$clonedObj->statut=0;
|
||||||
|
|
||||||
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
|
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
|
||||||
{
|
{
|
||||||
@ -993,32 +993,32 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
$this->user_author = $user->id;
|
$clonedObj->user_author = $user->id;
|
||||||
$this->user_valid = '';
|
$clonedObj->user_valid = '';
|
||||||
$this->date = $now;
|
$clonedObj->date = $now;
|
||||||
$this->datep = $now; // deprecated
|
$clonedObj->datep = $now; // deprecated
|
||||||
$this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
|
$clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600);
|
||||||
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = '';
|
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = '';
|
||||||
|
|
||||||
// Set ref
|
// Set ref
|
||||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
|
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
|
||||||
$obj = $conf->global->PROPALE_ADDON;
|
$obj = $conf->global->PROPALE_ADDON;
|
||||||
$modPropale = new $obj;
|
$modPropale = new $obj;
|
||||||
$this->ref = $modPropale->getNextValue($objsoc,$this);
|
$clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj);
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result=$this->create($user);
|
$result=$clonedObj->create($user);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// copy internal contacts
|
// copy internal contacts
|
||||||
if ($this->copy_linked_contact($objFrom, 'internal') < 0)
|
if ($clonedObj->copy_linked_contact($this, 'internal') < 0)
|
||||||
$error++;
|
$error++;
|
||||||
|
|
||||||
// copy external contacts if same company
|
// copy external contacts if same company
|
||||||
elseif ($objFrom->socid == $this->socid)
|
elseif ($this->socid == $clonedObj->socid)
|
||||||
{
|
{
|
||||||
if ($this->copy_linked_contact($objFrom, 'external') < 0)
|
if ($clonedObj->copy_linked_contact($this, 'external') < 0)
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1028,16 +1028,16 @@ class Propal extends CommonObject
|
|||||||
// Hook of thirdparty module
|
// Hook of thirdparty module
|
||||||
if (is_object($hookmanager))
|
if (is_object($hookmanager))
|
||||||
{
|
{
|
||||||
$parameters=array('objFrom'=>$objFrom);
|
$parameters=array('objFrom'=>$this);
|
||||||
$action='';
|
$action='';
|
||||||
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$clonedObj,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) $error++;
|
if ($reshook < 0) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('PROPAL_CLONE',$clonedObj,$user,$langs,$conf);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++; $this->errors=$interface->errors;
|
$error++; $this->errors=$interface->errors;
|
||||||
}
|
}
|
||||||
@ -1048,7 +1048,7 @@ class Propal extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->id;
|
return $clonedObj->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user