From ba93ccaa0148283aa28eff5e51b94144483d7da9 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Fri, 16 Apr 2021 10:56:01 +0100 Subject: [PATCH] Decline reason for partnership management --- htdocs/langs/en_US/partnership.lang | 2 ++ htdocs/partnership/admin/about.php | 4 ++-- .../partnership/class/partnership.class.php | 19 +++++++++++-------- htdocs/partnership/partnership_card.php | 8 ++++++-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 758a44546fb..3ac04a5bae0 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -40,6 +40,8 @@ PartnershipManagedFor=Partnership managed for PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party DatePartnershipStart=Start date DatePartnershipEnd=End date +ReasonDecline=Decline reason +ReasonDeclineOrCancel=Decline reason # # Template Mail diff --git a/htdocs/partnership/admin/about.php b/htdocs/partnership/admin/about.php index 2d5f17b1877..c8a01516ed6 100644 --- a/htdocs/partnership/admin/about.php +++ b/htdocs/partnership/admin/about.php @@ -87,13 +87,13 @@ llxHeader('', $langs->trans($page_name)); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_partnership@partnership'); +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = partnershipAdminPrepareHead(); print dol_get_fiche_head($head, 'about', '', 0, 'partnership@partnership'); -dol_include_once('/partnership/core/modules/modPartnership.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/modules/modPartnership.class.php'; $tmpmodule = new modPartnership($db); print $tmpmodule->getDescLong(); diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index c772ff47326..fd0233d3fef 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -849,21 +849,24 @@ class Partnership extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, 0=Nothing done, >0 if OK */ - public function refused($user, $notrigger = '') + public function refused($user, $reasondeclinenote = '', $notrigger = 0) { // Protection if ($this->status == self::STATUS_REFUSED) { return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ + $this->status = self::STATUS_REFUSED; + $this->reason_decline_or_cancel = $reasondeclinenote; - return $this->setStatusCommon($user, self::STATUS_REFUSED, $notrigger, 'PARTNERSHIP_REFUSE'); + $result = $this->update($user); + + if ($result) { + $this->reason_decline_or_cancel = $reasondeclinenote; + return 1; + } + + return -1; } /** diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index cb082dc640d..2e6e43ac47e 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -209,10 +209,13 @@ if (empty($reshook)) { if ($object->statut != $object::STATUS_REFUSED) { $db->begin(); - $result = $object->refused($user, GETPOST('reason_decline_or_cancel', 'alpha')); + $result = $object->refused($user, GETPOST('reason_decline_or_cancel', 'restricthtml')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; + } else { + $object->reason_decline_or_cancel = GETPOST('reason_decline_or_cancel', 'restricthtml'); + } if (!$error) { @@ -249,6 +252,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED) $object->fields['reason_decline_or_cancel']['visible'] = 3; @@ -400,7 +404,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'refuse') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel minwidth400', 'value' => '') // Field to complete private note (not replace) ); // if (!empty($conf->notification->enabled)) {