From 81f1bee10ce5e6ef224e074d24c016aefd71f03f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Mar 2021 11:18:14 +0100 Subject: [PATCH] Fix option DONATION_USE_THIRDPARTIES --- htdocs/don/card.php | 46 +++++++++++++++++++------------ htdocs/langs/en_US/donations.lang | 2 +- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index c55751e913f..dd7de85430e 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -44,7 +44,7 @@ if (!empty($conf->projet->enabled)) { } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$langs->loadLangs(array("bills", "companies", "donations")); +$langs->loadLangs(array("bills", "companies", "donations", "users")); $id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); @@ -179,15 +179,18 @@ if ($action == 'add') $error = 0; - if (empty($donation_date)) - { + if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); + $action = "create"; + $error++; + } + if (empty($donation_date)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = "create"; $error++; } - if (empty($amount)) - { + if (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); $action = "create"; $error++; @@ -347,16 +350,16 @@ if ($action == 'create') print ''; // Ref - print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; + print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; // Company if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { // Thirdparty - print ''.$langs->trans('Customer').''; - if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha')) + if ($soc->id > 0) { - print ''; + print ''.$langs->trans('ThirdParty').''; + print ''; print $soc->getNomUrl(1); print ''; // Outstanding Bill @@ -372,7 +375,8 @@ if ($action == 'create') print ')'; print ''; } else { - print ''; + print ''.$langs->trans('ThirdParty').''; + print ''; print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) @@ -389,7 +393,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '; print ''; } print ''."\n"; @@ -545,11 +549,15 @@ if (!empty($id) && $action == 'edit') print ""; print "\n"; - if ($object->socid && !empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { $company = new Societe($db); - $result = $company->fetch($object->socid); - print ''.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).''; + print ''.$langs->trans("ThirdParty").''; + if ($object->socid > 0) { + $result = $company->fetch($object->socid); + print $company->getNomUrl(1); + } + print ''; } else { $langs->load("companies"); print ''.$langs->trans("Company").''; @@ -707,11 +715,15 @@ if (!empty($id) && $action != 'edit') print yn($object->public); print ''; - if ($object->socid) { + if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { $company = new Societe($db); - $result = $company->fetch($object->socid); - print ''.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).''; + print ''.$langs->trans("ThirdParty").''; + if ($object->socid > 0) { + $result = $company->fetch($object->socid); + print $company->getNomUrl(1); + } + print ''; } else { print ''.$langs->trans("Company").''.$object->societe.''; print ''.$langs->trans("Lastname").''.$object->lastname.''; diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 2f897556d5c..d512abb2eea 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -32,4 +32,4 @@ DONATION_ART238=Show article 238 from CGI if you are concerned DONATION_ART885=Show article 885 from CGI if you are concerned DonationPayment=Donation payment DonationValidated=Donation %s validated -DonationUseThirdparties=Ask a thirdparty on each donation record +DonationUseThirdparties=Use an existing thirdparty as coordinates of donators