diff --git a/ChangeLog b/ChangeLog index 00a99cef9732223625dacbb74e3f5a4ad149c213..4304564ef04830bcc62ba0ed879e783e3a732151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -315,7 +315,7 @@ For users: - New: Can list elements (invoices, orders or proposals) on a particular user contact). This allow to view a "basket" of its elements. - New: Show bank account on payment list of invoice card. -- New: Cloning project allow to clones task, notes, files, contacts. +- New: Cloning project allow to clones task, notes, projects files, tasks files, contacts. - New: Enhance default style. - New: Can edit and resiliate member status from list. - New: Can insert URL links into elements lines. Also reported into PDF. diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 066732aa22a5e3e5397cc8d03c5cb4fae39e433a..196230c110b33d892e75e5c0c702d6b6e1c84c5a 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -89,7 +89,8 @@ CloneProject=Clone project CloneTasks=Clone tasks CloneContacts=Clone contacts CloneNotes=Clone notes -CloneFiles=Clone joined files +CloneProjectFiles=Clone project joined files +CloneTaskFiles=Clone task(s) joined files (if task(s) cloned) ConfirmCloneProject=Are you sure to clone this project ? ProjectReportDate=Change task date according project start date ErrorShiftTaskDate=Impossible to shift task date according to new project start date diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e6644c048c56110c1e52a8f87d3e2a5981db379c..fc88d75cb95410a9c69a7accc7383d3e213a6066 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -970,11 +970,13 @@ class Project extends CommonObject * @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_file clone file 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 $notrigger no trigger flag * @return int New id of clone */ - function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_file=false,$clone_note=true) + function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$notrigger=0) { global $user,$langs,$conf; @@ -1025,7 +1027,7 @@ class Project extends CommonObject $clone_project->ref=$defaultref; // Create clone - $result=$clone_project->create($user); + $result=$clone_project->create($user,$notrigger); // Other options if ($result < 0) @@ -1088,7 +1090,7 @@ class Project extends CommonObject foreach ($tab as $contacttoadd) { - $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source']); + $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'],$notrigger); if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); @@ -1108,7 +1110,7 @@ class Project extends CommonObject } //Duplicate file - if ($clone_file) + if ($clone_project_file) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1151,7 +1153,7 @@ class Project extends CommonObject foreach ($tasksarray as $tasktoclone) { - $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,true,true,false,true,true,false); + $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,true,true,false,$clone_task_file,true,false); if ($result_clone <= 0) { $this->error.=$result_clone->error; @@ -1181,7 +1183,7 @@ class Project extends CommonObject { $taskstatic->fk_task_parent=$tab_conv_child_parent[$taskstatic->fk_task_parent]; } - $res=$taskstatic->update($user); + $res=$taskstatic->update($user,$notrigger); if ($result_clone <= 0) { $this->error.=$taskstatic->error; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 1f5529d688b925dd3d5765d9298d4efc9dd93344..5abf23e6df3d1b4540d2959af2107d4c16c6fe62 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1083,6 +1083,7 @@ class Task extends CommonObject $this->db->commit(); $clone_task_id=$clone_task->id; + $clone_task_ref = $clone_task->ref; //Note Update if (!$clone_note) @@ -1139,7 +1140,7 @@ class Task extends CommonObject $clone_project_ref=$ori_project_ref; } - $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_id); + $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_ref); $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid); $filearray=dol_dir_list($ori_task_dir,"files",0,'','\.meta$','',SORT_ASC,1); diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index a07e3755fa59ec8eef421e7cd0dda00b3930d36a..bce51a1028a389e9f76d2d1c00ce202744bc568b 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -314,9 +314,10 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi { $clone_contacts=GETPOST('clone_contacts')?1:0; $clone_tasks=GETPOST('clone_tasks')?1:0; - $clone_files=GETPOST('clone_files')?1:0; + $clone_project_files = GETPOST ( 'clone_project_files' ) ? 1 : 0; + $clone_task_files = GETPOST ( 'clone_task_files' ) ? 1 : 0; $clone_notes=GETPOST('clone_notes')?1:0; - $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_files,$clone_notes); + $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes); if ($result <= 0) { $mesg='<div class="error">'.$object->error.'</div>'; @@ -479,10 +480,11 @@ else { $formquestion=array( 'text' => $langs->trans("ConfirmClone"), - 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' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_files', 'label' => $langs->trans("CloneFiles"), 'value' => false) + 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' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans ( "CloneProjectFiles" ), 'value' => false), + 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);