From 3eff91a6dc7cb259906cfd18d6dc59d6e5b1431f Mon Sep 17 00:00:00 2001 From: atm-steve Date: Wed, 22 Jun 2022 10:50:54 +0200 Subject: [PATCH 1/2] wip: popin with new fileds --- htdocs/contrat/card.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 87d6b98475b..df74c8dbf25 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1261,7 +1261,24 @@ if ($action == 'create') { // 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); + //$sql = "SELECT date_ouverture, date_cloture, commentaire FROM " . MAIN_DB_PREFIX ."contratdet WHERE fk_contrat = " . $object->id; + ////$sql.= ""; +// + //$result = $db->query($sql); + //if ($result) { + // $objp = $db->fetch_object($result); + //} +// + //// Definie date debut et fin par defaut + //$dateactstart = $objp->date_ouverture; + //$dateactend = $objp->date_cloture; + //$comment = $objp->commentaire; + $formquestion = array( + array('type' => 'other', 'name' => 'active', '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' => 'other', 'name' => 'active', 'label' => $langs->trans("DateEndPlanned"), 'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0), '', ''), + array('type' => 'text', 'comment' => 'active', '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)'))); From 3d7904c404f970a5523ee96d53d25d923ae18e62 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Wed, 22 Jun 2022 12:05:39 +0200 Subject: [PATCH 2/2] feat: activate all services on contrat --- htdocs/contrat/card.php | 24 +++++++----------------- htdocs/contrat/class/contrat.class.php | 4 ++-- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index df74c8dbf25..0254efdbe95 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -785,8 +785,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'); } @@ -1261,22 +1263,10 @@ if ($action == 'create') { // 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') { - //$sql = "SELECT date_ouverture, date_cloture, commentaire FROM " . MAIN_DB_PREFIX ."contratdet WHERE fk_contrat = " . $object->id; - ////$sql.= ""; -// - //$result = $db->query($sql); - //if ($result) { - // $objp = $db->fetch_object($result); - //} -// - //// Definie date debut et fin par defaut - //$dateactstart = $objp->date_ouverture; - //$dateactend = $objp->date_cloture; - //$comment = $objp->commentaire; $formquestion = array( - array('type' => 'other', 'name' => 'active', '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' => 'other', 'name' => 'active', 'label' => $langs->trans("DateEndPlanned"), 'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0), '', ''), - array('type' => 'text', 'comment' => 'active', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') + 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') { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4e4437c1b2c..87f728b18a4 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;