diff --git a/ChangeLog b/ChangeLog index 3bc56c5de5b..a59cf9b7006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.5 compared to 3.6.4 ***** - Fix: [ bug #1776 ] Undefined $deliverycompany variable in pdf_build_address +- Fix: [ bug #1794 ] Error when cloning Proposal gives error in a malformed page ***** ChangeLog for 3.6.4 compared to 3.6.3 ***** - Fix: [ bug #2893 ] Dolibarr error when viewing an invoice after changing invoice mask diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 99119414971..aefef2af68e 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -112,20 +112,20 @@ if (empty($reshook)) { // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } else { +// if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { +// setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); +// } else { if ($object->id > 0) { $result = $object->createFromClone($socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); } else { - setEventMessage($object->error, 'errors'); + if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); $action = ''; } } - } +// } } // Delete proposal diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 483b6ec8258..ba361ea6aa5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -956,35 +956,35 @@ class Propal extends CommonObject foreach($this->lines as $line) $line->fetch_optionals($line->rowid); - // Load source object - $objFrom = dol_clone($this); + // Load dest object + $clonedObj = clone $this; $objsoc=new Societe($this->db); // Change socid if needed - if (! empty($socid) && $socid != $this->socid) + if (! empty($socid) && $socid != $clonedObj->socid) { if ($objsoc->fetch($socid) > 0) { - $this->socid = $objsoc->id; - $this->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); - $this->fk_project = ''; - $this->fk_delivery_address = ''; + $clonedObj->socid = $objsoc->id; + $clonedObj->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $clonedObj->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $clonedObj->fk_project = ''; + $clonedObj->fk_delivery_address = ''; } // reset ref_client - $this->ref_client = ''; + $clonedObj->ref_client = ''; // TODO Change product price if multi-prices } else { - $objsoc->fetch($this->socid); + $objsoc->fetch($clonedObj->socid); } - $this->id=0; - $this->statut=0; + $clonedObj->id=0; + $clonedObj->statut=0; 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 - $this->user_author = $user->id; - $this->user_valid = ''; - $this->date = $now; - $this->datep = $now; // deprecated - $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); - if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; + $clonedObj->user_author = $user->id; + $clonedObj->user_valid = ''; + $clonedObj->date = $now; + $clonedObj->datep = $now; // deprecated + $clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600); + if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; // Set ref require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php'; $obj = $conf->global->PROPALE_ADDON; $modPropale = new $obj; - $this->ref = $modPropale->getNextValue($objsoc,$this); + $clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj); // Create clone - $result=$this->create($user); + $result=$clonedObj->create($user); if ($result < 0) $error++; else { // copy internal contacts - if ($this->copy_linked_contact($objFrom, 'internal') < 0) + if ($clonedObj->copy_linked_contact($this, 'internal') < 0) $error++; // 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++; } } @@ -1028,16 +1028,16 @@ class Propal extends CommonObject // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); + $parameters=array('objFrom'=>$this); $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++; } // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $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) { $error++; $this->errors=$interface->errors; } @@ -1048,7 +1048,7 @@ class Propal extends CommonObject if (! $error) { $this->db->commit(); - return $this->id; + return $clonedObj->id; } else {