Skip to content
Snippets Groups Projects
Commit 2a6ab476 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

NEW Can change thirdparty when cloning a project.

parent 2600b286
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment