diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 62a5a8fd3f1ba4d82748e180ff219682be8011ca..af6d4e7c591fa455c070b0e78fd2cc7b7f246ba2 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -376,14 +376,21 @@ if (empty($reshook)) $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; $clone_notes=GETPOST('clone_notes')?1:0; $move_date=GETPOST('move_date')?1:0; - $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes,$move_date); + $clone_thirdparty=GETPOST('socid','int')?GETPOST('socid','int'):0; + + $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes,$move_date,0,$clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - $object->fetch($result); // Load new object + // Load new object + $newobject=new Project($db); + $newobject->fetch($result); + $newobject->fetch_optionals(); + $newobject->fetch_thirdparty(); // Load new object + $object=$newobject; $action='edit'; $comefromclone=true; } @@ -623,6 +630,7 @@ else { $formquestion=array( 'text' => $langs->trans("ConfirmClone"), + array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None")), array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), @@ -631,7 +639,7 @@ else array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300); } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8791028beda29ae1fcc2dffac065a83e5d60095a..d5765f102d586b1caddd5190ef9e89f4a284144a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1123,16 +1123,17 @@ class Project extends CommonObject * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone - * @param bool $clone_contact clone contact of project - * @param bool $clone_task clone task of project - * @param bool $clone_project_file clone file of project - * @param bool $clone_task_file clone file of task (if task are copied) - * @param bool $clone_note clone note of project - * @param bool $move_date move task date on clone - * @param integer $notrigger no trigger flag + * @param bool $clone_contact Clone contact of project + * @param bool $clone_task Clone task of project + * @param bool $clone_project_file Clone file of project + * @param bool $clone_task_file Clone file of task (if task are copied) + * @param bool $clone_note Clone note of project + * @param bool $move_date Move task date on clone + * @param integer $notrigger No trigger flag + * @param int $newthirdpartyid New thirdparty id * @return int New id of clone */ - function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$move_date=true,$notrigger=0) + function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$move_date=true,$notrigger=0,$newthirdpartyid=0) { global $user,$langs,$conf; @@ -1151,6 +1152,7 @@ class Project extends CommonObject // Load source object $clone_project->fetch($fromid); $clone_project->fetch_optionals(); + if ($newthirdpartyid > 0) $clone_project->socid = $newthirdpartyid; $clone_project->fetch_thirdparty(); $orign_dt_start=$clone_project->date_start;