From c131bdcbd307301a70d28f165d62410216bf9071 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 24 Jan 2022 16:06:02 +0100 Subject: [PATCH 1/3] NEW : Add hooks on salaries and sociales card --- htdocs/compta/sociales/card.php | 28 +++++++++++++++++++++++++--- htdocs/salaries/card.php | 20 +++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 7454f61f6de..f0dd02eac80 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -56,6 +56,9 @@ $label = GETPOST('label', 'alpha'); $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('propalcard', 'globalcard')); + $object = new ChargeSociales($db); if ($id > 0) { $object->fetch($id); @@ -74,6 +77,12 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges') * Actions */ +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + // Classify paid if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { $object->fetch($id); @@ -416,6 +425,8 @@ if ($id > 0) { $object = new ChargeSociales($db); $result = $object->fetch($id); + $formconfirm = ''; + if ($result > 0) { $head = tax_prepare_head($object); @@ -433,25 +444,36 @@ if ($id > 0) { $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); } - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } if ($action == 'paid') { $text = $langs->trans('ConfirmPaySocialContribution'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2); } // Confirmation of the removal of the Social Contribution if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteSocialContribution'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2); } if ($action == 'edit') { print "
id&action=update\" method=\"post\">"; print ''; } + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; print dol_get_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill'); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index f5ebbcf0ec6..dc1a98209f4 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -647,6 +647,7 @@ if ($action == 'create') { if ($id) { $head = salaries_prepare_head($object); + $formconfirm = ''; if ($action === 'clone') { $formquestion = array( @@ -657,17 +658,17 @@ if ($id) { $formquestion[] = array('type' => 'date', 'name' => 'clone_date_start', 'label' => $langs->trans("DateStart"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_date_end', 'label' => $langs->trans("DateEnd"), 'value' => -1); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneSalary', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneSalary', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } if ($action == 'paid') { $text = $langs->trans('ConfirmPaySalary'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySalary'), $text, "confirm_paid", '', '', 2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySalary'), $text, "confirm_paid", '', '', 2); } if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteSalary'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSalary'), $text, 'confirm_delete', '', '', 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSalary'), $text, 'confirm_delete', '', '', 2); } if ($action == 'edit') { @@ -675,6 +676,19 @@ if ($id) { print ''; } + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary'); $linkback = ''.$langs->trans("BackToList").''; From 6cb97b1346fdbbebc08cf0ea477517d84d9171a4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Jan 2022 15:13:40 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/compta/sociales/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index f0dd02eac80..d1ef5c1ea08 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -426,7 +426,7 @@ if ($id > 0) { $result = $object->fetch($id); $formconfirm = ''; - + if ($result > 0) { $head = tax_prepare_head($object); From 37338f9a6025b4f0a2f671f3dbcb6f217bf9e1c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jan 2022 14:03:29 +0100 Subject: [PATCH 3/3] Update card.php --- htdocs/compta/sociales/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index d1ef5c1ea08..888d3c77d6c 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -57,7 +57,7 @@ $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('propalcard', 'globalcard')); +$hookmanager->initHooks(array('taxcard', 'globalcard')); $object = new ChargeSociales($db); if ($id > 0) {