diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php
index 31fa1547ffc..1a0666d1067 100644
--- a/htdocs/projet/tasks/task.php
+++ b/htdocs/projet/tasks/task.php
@@ -128,6 +128,28 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) {
}
}
+if ($action == 'confirm_clone' && $confirm == 'yes') {
+ //$clone_contacts = GETPOST('clone_contacts') ? 1 : 0;
+ $clone_prog = GETPOST('clone_prog') ? 1 : 0;
+ $clone_time = GETPOST('clone_time') ? 1 : 0;
+ $clone_affectation = GETPOST('clone_affectation') ? 1 : 0;
+ $clone_change_dt = GETPOST('clone_change_dt') ? 1 : 0;
+ $clone_notes = GETPOST('clone_notes') ? 1 : 0;
+ $clone_file = GETPOST('clone_file') ? 1 : 0;
+ $result = $object->createFromClone($user, $object->id, $object->fk_project, $object->fk_task_parent, $clone_change_dt, $clone_affectation, $clone_time, $clone_file, $clone_notes, $clone_prog);
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ } else {
+ // Load new object
+ $newobject = new Task($db);
+ $newobject->fetch($result);
+ $newobject->fetch_optionals();
+ $newobject->fetch_thirdparty(); // Load new object
+ $object = $newobject;
+ $action = '';
+ }
+}
+
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) {
$result = $projectstatic->fetch($object->fk_project);
$projectstatic->fetch_thirdparty();
@@ -205,6 +227,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
+
if ($id > 0 || !empty($ref)) {
$res = $object->fetch_optionals();
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) {
@@ -385,6 +408,22 @@ if ($id > 0 || !empty($ref)) {
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$object->getListContactId('internal');
+ if ($action == 'clone') {
+ $formquestion = array(
+ 'text' => $langs->trans("ConfirmClone"),
+ //array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
+ array('type' => 'checkbox', 'name' => 'clone_change_dt', 'label' => $langs->trans("CloneChanges"), 'value' => true),
+ array('type' => 'checkbox', 'name' => 'clone_affectation', 'label' => $langs->trans("CloneAffectation"), 'value' => true),
+ array('type' => 'checkbox', 'name' => 'clone_prog', 'label' => $langs->trans("CloneProgression"), 'value' => true),
+ array('type' => 'checkbox', 'name' => 'clone_time', 'label' => $langs->trans("CloneTimes"), 'value' => true),
+ array('type' => 'checkbox', 'name' => 'clone_file', 'label' => $langs->trans("CloneFile"), 'value' => true),
+
+ );
+
+ print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneTask"), "confirm_clone", $formquestion, '', 1, 300, 590);
+ }
+
+
$head = task_prepare_head($object);
if ($action == 'edit' && $user->rights->projet->creer) {
@@ -628,6 +667,7 @@ if ($id > 0 || !empty($ref)) {
// Modify
if ($user->rights->projet->creer) {
print ''.$langs->trans('Modify').'';
+ print ''.$langs->trans('Clone').'';
} else {
print ''.$langs->trans('Modify').'';
}