diff --git a/htdocs/admin/security_captcha.php b/htdocs/admin/security_captcha.php
index 0128605a0eb..f495da241c3 100644
--- a/htdocs/admin/security_captcha.php
+++ b/htdocs/admin/security_captcha.php
@@ -188,6 +188,20 @@ if (isModEnabled('member')) {
}
}
+if (isModEnabled('don')) {
+ print ' ';
+ print $langs->trans("UseCaptchaCode").' - Donation public form';
+ if (!empty($conf->use_javascript_ajax)) {
+ print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_DONATION', array(), null, 0, 0, 1);
+ } else {
+ if (!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_DONATION')) {
+ print ''.img_picto($langs->trans("Disabled"), 'off').'';
+ } else {
+ print ''.img_picto($langs->trans("Enabled"), 'on').'';
+ }
+ }
+}
+
// Set if a captcha is used on at least one place
$showavailablecaptcha = 0;
if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) {
@@ -202,6 +216,9 @@ if (isModEnabled('ticket') && getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TI
if (isModEnabled('member') && getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER')) {
$showavailablecaptcha = 1;
}
+if (isModEnabled('don') && getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_DONATION')) {
+ $showavailablecaptcha = 1;
+}
$selectedcaptcha = getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_HANDLER', 'standard');
diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php
index 2c8077c2632..f08da546f3c 100644
--- a/htdocs/core/lib/donation.lib.php
+++ b/htdocs/core/lib/donation.lib.php
@@ -59,6 +59,13 @@ function donation_admin_prepare_head()
complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
+ $head[$h][0] = DOL_URL_ROOT.'/don/admin/website.php';
+ $head[$h][1] = $langs->trans("BlankSubscriptionForm");
+ $head[$h][2] = 'website';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
+
return $head;
}
diff --git a/htdocs/don/admin/website.php b/htdocs/don/admin/website.php
new file mode 100644
index 00000000000..f77af25017b
--- /dev/null
+++ b/htdocs/don/admin/website.php
@@ -0,0 +1,240 @@
+
+ * Copyright (C) 2006-2015 Laurent Destailleur
+ * Copyright (C) 2006-2012 Regis Houssin
+ * Copyright (C) 2011 Juanjo Menent
+ * Copyright (C) 2024 Alexandre Spangaro
+ * Copyright (C) 2024 Frédéric France
+ * Copyright (C) 2025 MDW
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/don/admin/website.php
+ * \ingroup don
+ * \brief File of main public page for donation module
+ */
+
+// Load Dolibarr environment
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
+
+
+/**
+ * @var Conf $conf
+ * @var DoliDB $db
+ * @var HookManager $hookmanager
+ * @var Translate $langs
+ * @var User $user
+ *
+ * @var string $dolibarr_main_url_root
+ */
+
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "donations"));
+
+$action = GETPOST('action', 'aZ09');
+
+if (!$user->admin) {
+ accessforbidden();
+}
+
+$error = 0;
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'setDONATION_ENABLE_PUBLIC') {
+ if (GETPOST('value')) {
+ dolibarr_set_const($db, 'DONATION_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'DONATION_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
+ }
+}
+
+if ($action == 'update') {
+ $public = GETPOST('DONATION_ENABLE_PUBLIC');
+
+ $minamount = GETPOST('DONATION_MIN_AMOUNT');
+ $publiccounters = GETPOST('DONATION_COUNTERS_ARE_PUBLIC');
+ $payonline = GETPOST('DONATION_NEWFORM_PAYONLINE');
+
+ $res = dolibarr_set_const($db, "DONATION_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "DONATION_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "DONATION_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, "DONATION_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
+
+ if (!($res > 0)) {
+ $error++;
+ }
+
+ if (!$error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$title = $langs->trans("DonationsSetup");
+
+llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-don page-admin_website');
+
+
+$linkback = ''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($title, $linkback, 'title_setup');
+
+$head = donation_admin_prepare_head();
+
+
+
+print '';
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang
index eaebe7c2b03..523e7955fd0 100644
--- a/htdocs/langs/en_US/donations.lang
+++ b/htdocs/langs/en_US/donations.lang
@@ -36,3 +36,23 @@ DonationValidated=Donation %s validated
DonationUseThirdparties=Use the address of an existing thirdparty as the address of the donor
DonationsStatistics=Donation's statistics
NbOfDonations=Number of donations
+BlankDonationForm=Public donation form
+BlankDonationFormDesc=Dolibarr can provide you a public URL/website to allow external visitors to make a donation. If an online payment module is enabled, a payment form may also be automatically provided.
+EnablePublicDonationForm=Enable the public donation form
+EnablePublicDonationList=Enable the public donation List
+ForceDonateurNature = Force donateur nature (Individual or Corporation)
+MinimumAmountDonation=Minimum amount of donation payment
+donationCountersArePublic = The total amount of valid donations is publicly visible
+DONATION_NEWFORM_PAYONLINE=After the donation form, switch automatically to the online payment page
+ErrorFieldMinimumAmount=Minimum amount of donation is %s
+NewDonationForm=New donation form
+NewDonationbyWeb=New donation added. Awaiting for payment
+NewDonationDesc=This form allows you to make a donation.
+donationPublic=Public donation
+donationAmount=Contribution Amount
+GetDonationButtonLabel=Donate
+AnyAmountForDonation=Any amount of your choice
+project=Cause
+donAnonymous=Anonymous donation
+AnonymousDonationTooltip=Check this box if you want your donation to remain anonymous. Your personal information will not be asked.
+publicDonationFieldHelp=%s can publish my donation in the public register
diff --git a/htdocs/public/donations/new.php b/htdocs/public/donations/new.php
new file mode 100644
index 00000000000..afb141f6c2c
--- /dev/null
+++ b/htdocs/public/donations/new.php
@@ -0,0 +1,557 @@
+
+ * Copyright (C) 2001-2002 Jean-Louis Bergamo
+ * Copyright (C) 2006-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2012 J. Fernando Lagrange
+ * Copyright (C) 2018-2024 Frédéric France
+ * Copyright (C) 2018 Alexandre Spangaro
+ * Copyright (C) 2021 Waël Almoman
+ * Copyright (C) 2022 Udo Tamm
+ * Copyright (C) 2024-2025 MDW
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/donations/new.php
+ * \ingroup don
+ * \brief Example of form to add a new donation
+ *
+ * Note that you can add following constant to change behaviour of page
+ * DONATION_MIN_AMOUNT Minimum amount
+ * DONATION_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+// Because 2 entities can have the same ref.
+$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
+// if (is_numeric($entity)) { // $entity is casted to int
+define("DOLENTITY", $entity);
+// }
+
+
+// Load Dolibarr environment
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+if (isModEnabled('project') || isModEnabled('eventorganization')) {
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+}
+
+// Init vars
+$backtopage = GETPOST('backtopage', 'alpha');
+$action = GETPOST('action', 'aZ09');
+
+$errmsg = '';
+$num = 0;
+$error = 0;
+
+/**
+ * @var Conf $conf
+ * @var DoliDB $db
+ * @var HookManager $hookmanager
+ * @var Societe $mysoc
+ * @var Translate $langs
+ * @var User $user
+ */
+
+// Load translation files
+$langs->loadLangs(array("main", "donations", "companies", "install", "other", "errors"));
+
+// Security check
+if (!isModEnabled('don')) {
+ httponly_accessforbidden('Module don not enabled');
+}
+
+if (!getDolGlobalString('DONATION_ENABLE_PUBLIC')) {
+ httponly_accessforbidden("Donation form for public visitors has not been enabled");
+}
+
+// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
+//$hookmanager->initHooks(array( 'globalcard'));
+
+$extrafields = new ExtraFields($db);
+
+$object = new Don($db);
+
+$user->loadDefaultValues();
+
+
+/**
+ * Show header for new donation
+ *
+ * Note: also called by functions.lib:recordNotFound
+ *
+ * @param string $title Title
+ * @param string $head Head array
+ * @param int $disablejs More content into html header
+ * @param int $disablehead More content into html header
+ * @param string[]|string $arrayofjs Array of complementary js files
+ * @param string[]|string $arrayofcss Array of complementary css files
+ * @return void
+ */
+function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = []) // @phan-suppress-current-line PhanRedefineFunction
+{
+ global $conf, $langs, $mysoc;
+
+ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
+
+ print '';
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+ htmlPrintOnlineHeader($mysoc, $langs, 1, getDolGlobalString('DONATION_PUBLIC_INTERFACE'), 'DONATION_IMAGE_PUBLIC_REGISTRATION');
+
+ print '
';
+}
+
+/**
+ * Show footer for new donation
+ *
+ * Note: also called by functions.lib:recordNotFound
+ *
+ * @return void
+ */
+function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
+{
+ global $conf, $langs;
+
+ print '