Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 16.0
This commit is contained in:
commit
de8f115f95
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014-2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
|
||||
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||
*
|
||||
@ -254,6 +254,12 @@ if (empty($reshook)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
|
||||
if (!$error) {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -911,6 +911,8 @@ if ($resql) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// status
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('entrepot').')';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('stock').')';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid';
|
||||
}
|
||||
|
||||
@ -288,127 +288,129 @@ if (empty($reshook) && $action == 'add') {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$result = $adh->create($user);
|
||||
if ($result > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$object = $adh;
|
||||
if (!$error) {
|
||||
$result = $adh->create($user);
|
||||
if ($result > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$object = $adh;
|
||||
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
|
||||
if ($object->email) {
|
||||
$subject = '';
|
||||
$msg = '';
|
||||
if ($object->email) {
|
||||
$subject = '';
|
||||
$msg = '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content from template
|
||||
$arraydefaultmessage = null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER;
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content from template
|
||||
$arraydefaultmessage = null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER;
|
||||
|
||||
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;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
|
||||
|
||||
if ($subjecttosend && $texttosend) {
|
||||
$moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
|
||||
|
||||
$result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
|
||||
}
|
||||
/*if ($result < 0) {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
|
||||
|
||||
if ($subjecttosend && $texttosend) {
|
||||
$moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
|
||||
|
||||
$result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
|
||||
}
|
||||
/*if ($result < 0) {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}*/
|
||||
}
|
||||
|
||||
// Send email to the foundation to say a new member subscribed with autosubscribe form
|
||||
if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
|
||||
!empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) {
|
||||
// Define link to login card
|
||||
$appli = constant('DOL_APPLICATION_TITLE');
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
|
||||
$appli = $conf->global->MAIN_APPLICATION_TITLE;
|
||||
if (preg_match('/\d\.\d/', $appli)) {
|
||||
if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
|
||||
$appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
||||
// Send email to the foundation to say a new member subscribed with autosubscribe form
|
||||
if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
|
||||
!empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) {
|
||||
// Define link to login card
|
||||
$appli = constant('DOL_APPLICATION_TITLE');
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
|
||||
$appli = $conf->global->MAIN_APPLICATION_TITLE;
|
||||
if (preg_match('/\d\.\d/', $appli)) {
|
||||
if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
|
||||
$appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
|
||||
}
|
||||
} else {
|
||||
$appli .= " ".DOL_VERSION;
|
||||
}
|
||||
} else {
|
||||
$appli .= " ".DOL_VERSION;
|
||||
}
|
||||
|
||||
$to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
|
||||
$from = $conf->global->ADHERENT_MAIL_FROM;
|
||||
$mailfile = new CMailFile(
|
||||
'['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT,
|
||||
$to,
|
||||
$from,
|
||||
$adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
-1
|
||||
);
|
||||
|
||||
if (!$mailfile->sendfile()) {
|
||||
dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($backtopage)) {
|
||||
$urlback = $backtopage;
|
||||
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
|
||||
$urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
|
||||
// TODO Make replacement of __AMOUNT__, etc...
|
||||
} else {
|
||||
$appli .= " ".DOL_VERSION;
|
||||
$urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
|
||||
}
|
||||
|
||||
$to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
|
||||
$from = $conf->global->ADHERENT_MAIL_FROM;
|
||||
$mailfile = new CMailFile(
|
||||
'['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT,
|
||||
$to,
|
||||
$from,
|
||||
$adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
-1
|
||||
);
|
||||
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
|
||||
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed
|
||||
// TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT
|
||||
// It is not so important because a test is done on return of payment validation.
|
||||
}
|
||||
|
||||
if (!$mailfile->sendfile()) {
|
||||
dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
|
||||
$urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0);
|
||||
|
||||
if (GETPOST('email')) {
|
||||
$urlback .= '&email='.urlencode(GETPOST('email'));
|
||||
}
|
||||
if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') {
|
||||
$urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE);
|
||||
}
|
||||
} else {
|
||||
if (!empty($entity)) {
|
||||
$urlback .= '&entity='.((int) $entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($backtopage)) {
|
||||
$urlback = $backtopage;
|
||||
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
|
||||
$urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
|
||||
// TODO Make replacement of __AMOUNT__, etc...
|
||||
dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
|
||||
} else {
|
||||
$urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
|
||||
$error++;
|
||||
$errmsg .= join('<br>', $adh->errors);
|
||||
}
|
||||
|
||||
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
|
||||
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed
|
||||
// TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT
|
||||
// It is not so important because a test is done on return of payment validation.
|
||||
}
|
||||
|
||||
$urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0);
|
||||
|
||||
if (GETPOST('email')) {
|
||||
$urlback .= '&email='.urlencode(GETPOST('email'));
|
||||
}
|
||||
if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') {
|
||||
$urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE);
|
||||
}
|
||||
} else {
|
||||
if (!empty($entity)) {
|
||||
$urlback .= '&entity='.((int) $entity);
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
|
||||
} else {
|
||||
$error++;
|
||||
$errmsg .= join('<br>', $adh->errors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,6 +470,7 @@ if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) {
|
||||
print '</div>';
|
||||
|
||||
dol_htmloutput_errors($errmsg);
|
||||
dol_htmloutput_events();
|
||||
|
||||
// Print form
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user