Add project clone option : copy project files, copy task files
This commit is contained in:
parent
73263d4328
commit
9555cb35f0
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user