diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 937ec9b4b55..bc3b083f0a1 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -94,6 +94,7 @@ $hookmanager->initHooks(array('invoicecard'));
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer)
{
@@ -248,7 +249,6 @@ else if ($action == 'setmode' && $user->rights->facture->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
-
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
@@ -257,7 +257,14 @@ else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}
-
+else if ($action == 'setpaymentterm' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $object->date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
+ if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
+ $result=$object->update($user);
+ if ($result < 0) dol_print_error($db,$object->error);
+}
else if ($action == 'setconditions' && $user->rights->facture->creer)
{
$object->fetch($id);
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 971ab45376b..cbf6a1b7bf6 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2254,7 +2254,10 @@ class Form
if ($inputarray.length>0) {
$.each($inputarray, function() {
var inputname = this;
- var inputvalue = $("#" + this).val();
+ var more = \'\';
+ if ($("#" + this).attr("type") == \'checkbox\') { more = \':checked\'; }
+ var inputvalue = $("#" + this + more).val();
+ if (typeof inputvalue == \'undefined\') { inputvalue=\'\'; }
options += \'&\' + inputname + \'=\' + inputvalue;
});
//alert(options);
diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php
index bf4dc001e00..18f76aa105d 100644
--- a/htdocs/core/tpl/freeproductline_create.tpl.php
+++ b/htdocs/core/tpl/freeproductline_create.tpl.php
@@ -75,7 +75,7 @@
service->enabled && $dateSelector) { ?>
>
- | global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="10"' : ' colspan="9s"'); ?>>
+ | global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="10"' : ' colspan="9"'); ?>>
trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 75082f8012c..18844f91868 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -85,7 +85,11 @@ TaskIsNotAffectedToYou=Task not allocated to you
ErrorTimeSpentIsEmpty=Time spent is empty
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (%s tasks at the moment) and all inputs of time spent.
IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
-CloneProject=Clone project (associated task will be duplicated too)
+CloneProject=Clone project
+CloneTasks=Clone tasks
+CloneContacts=Clone contacts
+CloneNotes=Clone notes
+CloneFiles=Clone joined files
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/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 9c58ef9271b..7e07d70890b 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -603,7 +603,7 @@ Before=Avant
After=Après
IPAddress=Adresse IP
Frequency=Fréquence
-IM=Messagerie instantannée
+IM=Messagerie instantanée
NewAttribute=Nouvel attribut
AttributeCode=Code de l'attribut
OptionalFieldsSetup=Configuration des attributs complémentaires
diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang
index 0c3a21e4cdb..01c6b337e98 100644
--- a/htdocs/langs/fr_FR/projects.lang
+++ b/htdocs/langs/fr_FR/projects.lang
@@ -85,7 +85,11 @@ TaskIsNotAffectedToYou=Tâche qui ne vous est pas affectée
ErrorTimeSpentIsEmpty=Le temps consommé n'est pas renseigné
ThisWillAlsoRemoveTasks=Cette opération détruira également les tâches du projet (%s tâches actuellement) et le suivi des consommés.
IfNeedToUseOhterObjectKeepEmpty=Si des objets (facture, commande, ...), appartenant à un autre tiers que celui choisi, doivent être liés au projet à créer, laisser vide afin de laisser le projet multi-tiers.
-CloneProject=Cloner le projet (les taches associées sont dupliquées également)
+CloneProject=Cloner le projet
+CloneTasks=Cloner les taches
+CloneContacts=Cloner les contacts
+CloneNotes=Cloner les notes
+CloneFiles=Cloner les pièces jointes
ConfirmCloneProject=Êtes-vous sûr de vouloir cloner ce projet ?
ProjectReportDate=Reporter les dates des taches en fonction de la date de départ.
ErrorShiftTaskDate=Une erreur c'est produite dans le report des dates des taches.
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 1d76e6782c1..e1705991b30 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -777,13 +777,15 @@ if (! function_exists("llxHeader"))
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
* @return void
*/
- function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
- {
- top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
- top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
- left_menu('', $help_url, '', '', 1, $title);
- main_area($title);
- }
+ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
+ {
+ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
+ top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
+ if (empty($conf->global->MAIN_HIDE_LEFT_MENU)) {
+ left_menu('', $help_url, '', '', 1, $title);
+ }
+ main_area($title);
+ }
}
@@ -1172,11 +1174,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
/*
* Top menu
- */
+ */
$top_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu;
if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php
- // Load the top menu manager
// Load the top menu manager (only if not already done)
if (! class_exists('MenuTop'))
{
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 823ba1057f8..db565f2097d 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -883,21 +883,24 @@ class Project extends CommonObject
return $projects;
}
- /** 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_file clone file of project
- * @param bool $clone_note clone note of project
- * @return int New id of clone
- */
- function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_file=true,$clone_note=true)
+ /**
+ * 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_file clone file of project
+ * @param bool $clone_note clone note of project
+ * @return int New id of clone
+ */
+ function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_file=false,$clone_note=true)
{
global $user,$langs,$conf;
$error=0;
+ dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_file=".$clone_file." clone_note=".$clone_note);
+
$now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now()));
$clone_project=new Project($this->db);
@@ -908,30 +911,18 @@ class Project extends CommonObject
$clone_project->fetch($fromid);
$orign_dt_start=$clone_project->date_start;
-
-
$orign_project_ref=$clone_project->ref;
$clone_project->id=0;
$clone_project->date_start = $now;
if (!(empty($clone_project->date_end)))
{
- //Calculate new project end date ragarding difference between original project start date and new start date (now)
- $datetime_start = new DateTime();
- $datetime_start->setTimestamp($orign_dt_start);
- $datetime_now = new DateTime();
- $datetime_now->setTimestamp($now);
- $diff_dt = $datetime_start->diff($datetime_now);
-
- $datetime_end = new DateTime();
- $datetime_end->setTimestamp($clone_project->date_end);
- $datetime_end->add($diff_dt);
- $clone_project->date_end = $datetime_end->getTimestamp();
+ $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start);
}
$clone_project->datec = $now;
- if (!$clone_note)
+ if (! $clone_note)
{
$clone_project->note_private='';
$clone_project->note_public='';
@@ -1139,11 +1130,12 @@ class Project extends CommonObject
}
- /** Shift project task date from current date to delta
- *
- * @param timestamp $old_project_dt_start old project start date
- * @return int 1 if OK or < 0 if KO
- */
+ /**
+ * Shift project task date from current date to delta
+ *
+ * @param timestamp $old_project_dt_start old project start date
+ * @return int 1 if OK or < 0 if KO
+ */
function shiftTaskDate($old_project_dt_start)
{
global $user,$langs,$conf;
@@ -1156,11 +1148,6 @@ class Project extends CommonObject
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
- //convert timestamp to datetime
- $old_project_dt_st = new DateTime();
- $old_project_dt_st->setTimestamp($old_project_dt_start);
- $old_project_dt_st->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
-
$tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0);
foreach ($tasksarray as $tasktoshiftdate)
@@ -1183,39 +1170,13 @@ class Project extends CommonObject
//Calcultate new task start date with difference between old proj start date and origin task start date
if (!empty($tasktoshiftdate->date_start))
{
- dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
- $orign_task_datetime_start = new DateTime();
- $orign_task_datetime_start->setTimestamp($tasktoshiftdate->date_start);
- $orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side effect
- $diff_dt_st = $old_project_dt_st->diff($orign_task_datetime_start);
-
- //Project new start date
- $datetime_start = new DateTime();
- $datetime_start->setTimestamp($this->date_start);
- $datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
-
- //New task start date
- $datetime_start->add($diff_dt_st);
- $task->date_start = $datetime_start->getTimestamp();
+ $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_st);
}
//Calcultate new task end date with difference between origin proj end date and origin task end date
if (!empty($tasktoshiftdate->date_end))
{
- $orign_task_datetime_end = new DateTime();
- $orign_task_datetime_end->setTimestamp($tasktoshiftdate->date_end);
- $orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
-
- $diff_dt_end = $old_project_dt_st->diff($orign_task_datetime_end);
-
- //Project new start date
- $datetime_end = new DateTime();
- $datetime_end->setTimestamp($this->date_start);
- $datetime_end->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
-
- //New task start date
- $datetime_end->add($diff_dt_end);
- $task->date_end = $datetime_end->getTimestamp();
+ $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_st);
}
if ($to_update)
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index d1fdc88aedf..ab6a5a6840c 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -957,7 +957,7 @@ class Task extends CommonObject
$now=dol_now();
- $datec = dol_mktime(0,0,0,idate('m',$now),idate('d',$now),idate('Y',$now));
+ $datec = $now;
$clone_task=new Task($this->db);
@@ -980,41 +980,18 @@ class Task extends CommonObject
$projectstatic->fetch($ori_project_id);
//Origin project strat date
- $orign_project_dt_start = new DateTime();
- $orign_project_dt_start->setTimestamp($projectstatic->date_start);
+ $orign_project_dt_start = $projectstatic->date_start;
//Calcultate new task start date with difference between origin proj start date and origin task start date
if (!empty($clone_task->date_start))
{
- $orign_task_datetime_start = new DateTime();
- $orign_task_datetime_start->setTimestamp($clone_task->date_start);
- $orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
- $diff_dt_st = $orign_project_dt_start->diff($orign_task_datetime_start);
-
- //cloned project start date
- $datetime_start = new DateTime();
- $datetime_start->setTimestamp($now);
-
- //New task start date
- $datetime_start->add($diff_dt_st);
- $clone_task->date_start = $datetime_start->getTimestamp();
+ $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
}
//Calcultate new task end date with difference between origin proj end date and origin task end date
if (!empty($clone_task->date_end))
{
- $orign_task_datetime_end = new DateTime();
- $orign_task_datetime_end->setTimestamp($clone_task->date_end);
- $orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
- $diff_dt_end = $orign_project_dt_start->diff($orign_task_datetime_end);
-
- //cloned project start date
- $datetime_end = new DateTime();
- $datetime_end->setTimestamp($now);
-
- //New task start date
- $datetime_end->add($diff_dt_end);
- $clone_task->date_end = $datetime_end->getTimestamp();
+ $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
}
}
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index 1c6b0626ad1..d4293bea9ef 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -80,7 +80,7 @@ if (GETPOST("cancel") && ! empty($backtopage))
//if cancel and come from clone then delete the cloned project
if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
-{
+{
$project = new Project($db);
$project->fetch($id);
$result=$project->delete($user);
@@ -200,7 +200,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$result=$project->update($user);
$id=$project->id; // On retourne sur la fiche projet
-
+
if (GETPOST("reportdate") && ($project->date_start!=$old_start_date))
{
$result=$project->shiftTaskDate($old_start_date);
@@ -303,25 +303,11 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi
$idtoclone=$id;
$project = new Project($db);
$project->fetch($idtoclone);
- $result=$project->createFromClone($idtoclone,true,true,true,true);
- if ($result <= 0)
- {
- $mesg=' '.$project->error.' ';
- }
- else
- {
- $id=$result;
- $action='edit';
- $comefromclone=true;
- }
-}
-
-if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
-{
- $idtoclone=$id;
- $project = new Project($db);
- $project->fetch($idtoclone);
- $result=$project->createFromClone($idtoclone,true,true,true,true);
+ $clone_contacts=GETPOST('clone_contacts')?1:0;
+ $clone_tasks=GETPOST('clone_tasks')?1:0;
+ $clone_files=GETPOST('clone_files')?1:0;
+ $clone_notes=GETPOST('clone_notes')?1:0;
+ $result=$project->createFromClone($idtoclone,$clone_contacts,$clone_tasks,$clone_files,$clone_notes);
if ($result <= 0)
{
$mesg=''.$project->error.' ';
@@ -372,7 +358,7 @@ if ($action == 'create' && $user->rights->projet->creer)
{
require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php");
$modProject = new $obj;
- $defaultref = $modProject->getNextValue($soc,$project);
+ $defaultref = $modProject->getNextValue($soc,$project);
}
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
@@ -482,10 +468,17 @@ else
// Clone confirmation
if ($action == 'clone')
{
- $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1);
- if ($ret == 'html') print ' ';
+ $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)
+ );
+
+ print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$project->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240);
}
-
+
if ($action == 'edit' && $userWrite > 0)
{
print '';
}
else
@@ -580,7 +573,7 @@ else
// Date start
print ' |