From a0031901e42bf12981dbfdb8937b75c3c3c7708a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 11:36:03 +0100 Subject: [PATCH] complete doaction hook --- htdocs/adherents/subscription.php | 107 +++++++++++++++++------------- 1 file changed, 62 insertions(+), 45 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index a532c8c7e55..e19f01779aa 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify @@ -116,10 +116,12 @@ $paymentdate = -1; */ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // Create third party from a member -if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { +if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // Creation of thirdparty $company = new Societe($db); @@ -136,7 +138,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } } -if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { +if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error = 0; if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { @@ -155,7 +157,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights } } -if ($action == 'setsocid') { +if (empty($reshook) && $action == 'setsocid') { $error = 0; if (!$error) { if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database @@ -215,7 +217,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $emetteur_nom = $_POST["chqemetteur"]; $emetteur_banque = $_POST["chqbank"]; $option = $_POST["paymentsave"]; - if (empty($option)) $option = 'none'; + if (empty($option)) { + $option = 'none'; + } $sendalsoemail = GETPOST("sendmail", 'alpha'); // Check parameters @@ -254,11 +258,19 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! } else { if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { if ($_POST["subscription"]) { - if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + if (!$_POST["label"]) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + } + if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + } + if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) { + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + } } else { - if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + if ($_POST["accountid"]) { + $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + } } if ($errmsg) { $error++; @@ -340,7 +352,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; @@ -586,8 +600,8 @@ if ($rowid > 0) { /* - * Action buttons - */ + * Action buttons + */ // Button to create a new subscription if member no draft neither resiliated if ($user->rights->adherent->cotisation->creer) { @@ -602,8 +616,8 @@ if ($rowid > 0) { } /* - * List of subscriptions - */ + * List of subscriptions + */ if ($action != 'addsubscription' && $action != 'create_thirdparty') { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; $sql .= " c.rowid as crowid, c.subscription,"; @@ -723,8 +737,8 @@ if ($rowid > 0) { } /* - * Add new subscription form - */ + * Add new subscription form + */ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { print '
'; @@ -750,31 +764,31 @@ if ($rowid > 0) { //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); print "\n".''."\n"; @@ -925,8 +939,9 @@ if ($rowid > 0) { print 'fk_soc)) print ' disabled'; print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { + if ($object->fk_soc) { + print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + } else { print ' ('; if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); print $langs->trans("NoThirdPartyAssociatedToMember"); @@ -1005,7 +1020,9 @@ if ($rowid > 0) { $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic;