diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e44a023ec7c..0369516a030 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -784,8 +784,10 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { - // Close all lines - $result = $object->activateAll($user); + $date_start = dol_mktime(12, 0, 0, GETPOST('d_startmonth'), GETPOST('d_startday'), GETPOST('d_startyear')); + $date_end = dol_mktime(12, 0, 0, GETPOST('d_endmonth'), GETPOST('d_endday'), GETPOST('d_endyear')); + $comment = GETPOST('comment', 'alpha'); + $result = $object->activateAll($user, $date_start, 0, $comment, $date_end); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1260,7 +1262,12 @@ if ($action == 'create' || (empty($action) && empty($id))) { // Confirmation de la fermeture $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); } elseif ($action == 'activate') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); + $formquestion = array( + array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), /*'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0),*/ /*'socid', '(s.client=1 OR s.client=2 OR s.client=3)'*/), + array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ '', ''), + array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') + ); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280); } elseif ($action == 'clone') { // Clone confirmation $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ee59a5465dc..eea4e118397 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -369,7 +369,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see () */ - public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') + public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '', $date_end = '') { if (empty($date_start)) { $date_start = dol_now(); @@ -387,7 +387,7 @@ class Contrat extends CommonObject if ($contratline->statut != ContratLigne::STATUS_OPEN) { $contratline->context = $this->context; - $result = $contratline->active_line($user, $date_start, -1, $comment); // This call trigger LINECONTRACT_ACTIVATE + $result = $contratline->active_line($user, $date_start, !empty($date_end) ? $date_end : -1, $comment); // This call trigger LINECONTRACT_ACTIVATE if ($result < 0) { $error++; $this->error = $contratline->error;