';
@@ -580,11 +584,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
';
print '';
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 67bf775bdd9..0504315075d 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -88,7 +88,15 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
@@ -171,6 +179,24 @@ if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
+// List of oauth services
+$oauthservices = array();
+
+foreach ($conf->global as $key => $val) {
+ if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
+ $key = preg_replace('/^OAUTH_/', '', $key);
+ $key = preg_replace('/_ID$/', '', $key);
+ if (preg_match('/^.*-/', $key)) {
+ $name = preg_replace('/^.*-/', '', $key);
+ } else {
+ $name = $langs->trans("NoName");
+ }
+ $provider = preg_replace('/-.*$/', '', $key);
+ $provider = ucfirst(strtolower($provider));
+
+ $oauthservices[$key] = $name." (".$provider.")";
+ }
+}
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
@@ -195,6 +221,7 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
jQuery(".smtp_method").hide();
jQuery(".dkim").hide();
+ jQuery(".smtp_auth_method").hide();
';
if ($linuxlike) {
print '
@@ -237,6 +264,7 @@ if ($action == 'edit') {
jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
jQuery(".dkim").hide();
+ jQuery(".smtp_auth_method").show();
}
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
{
@@ -264,12 +292,34 @@ if ($action == 'edit') {
jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
jQuery(".dkim").show();
+ jQuery(".smtp_auth_method").show();
}
}
+ function change_smtp_auth_method() {
+ console.log(jQuery("#radio_pw").prop("checked"));
+ if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").hide();
+ } else {
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").show();
+ }
+ }
initfields();
+ change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE").change(function() {
initfields();
+ change_smtp_auth_method();
});
+ jQuery("#radio_pw, #radio_oauth").change(function() {
+ change_smtp_auth_method();
+ });
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
@@ -413,10 +463,29 @@ if ($action == 'edit') {
print '';
}
+
+ // OAUTH
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
+ print '
';
+ }
+
// PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
- print '
';
}
+ // OAUTH service provider
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
+ print '
';
// Host server
- if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
+ if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print '
';
}
+
// Port
- if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
+ if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print '
';
}
// SMTPS ID
- if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
print '
';
}
+ // AUTH method
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
+ $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
+ $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
+ print '
';
+ }
+
// SMTPS PW
- if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
print '
';
}
+ // SMTPS oauth service
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined").img_warning();
+ }
+ print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 8e31d0e6d62..db92c33a7fb 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -557,6 +557,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
+$totalarray['nbfield'] = 0;
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php
index 772055f0809..ade561c4ef1 100644
--- a/htdocs/admin/oauth.php
+++ b/htdocs/admin/oauth.php
@@ -62,7 +62,7 @@ if ($action == 'add') { // $provider is OAUTH_XXX
setEventMessages($langs->trans("AOAuthEntryForThisProviderAndLabelAlreadyHasAKey"), null, 'errors');
$error++;
} else {
- dolibarr_set_const($db, $constname, 'ToComplete', 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, $constname, $langs->trans('ToComplete'), 'chaine', 0, '', $conf->entity);
setEventMessages($langs->trans("OAuthProviderAdded"), null);
}
}
@@ -78,6 +78,16 @@ if ($action == 'update') {
if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) {
$error++;
}
+ if (GETPOSTISSET($constvalue.'_URLAUTHORIZE')) {
+ if (!dolibarr_set_const($db, $constvalue.'_URLAUTHORIZE', GETPOST($constvalue.'_URLAUTHORIZE'), 'chaine', 0, '', $conf->entity)) {
+ $error++;
+ }
+ }
+ if (GETPOSTISSET($constvalue.'_SCOPE')) {
+ if (!dolibarr_set_const($db, $constvalue.'_SCOPE', GETPOST($constvalue.'_SCOPE'), 'chaine', 0, '', $conf->entity)) {
+ $error++;
+ }
+ }
}
}
@@ -147,11 +157,17 @@ print '';
$i = 0;
-//var_dump($list);
+// Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
- $listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
+ $listinsetup[] = array(
+ $provider.'_NAME',
+ $provider.'_ID',
+ $provider.'_SECRET',
+ $provider.'_URLAUTHORIZE', // For custom oauth links
+ $provider.'_SCOPE' // For custom oauth links
+ );
}
}
@@ -178,12 +194,16 @@ foreach ($listinsetup as $key) {
$i++;
- print '';
// Api Name
$label = $langs->trans($keyforsupportedoauth2array);
+ print ' ';
print '';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
- print $label;
+ if ($label == $keyforsupportedoauth2array) {
+ print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+ } else {
+ print $label;
+ }
if ($keyforprovider) {
print ' ('.$keyforprovider.' )';
} else {
@@ -201,8 +221,15 @@ foreach ($listinsetup as $key) {
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print ' ';
print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
- print ' ';
+ print ' ';
print ' ';
+
+ if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
+ print '';
+ print ''.$langs->trans("URLOfServiceForAuthorization").' ';
+ print ' ';
+ print ' ';
+ }
} else {
print '';
print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
@@ -213,14 +240,32 @@ foreach ($listinsetup as $key) {
// Api Id
print ' ';
print ''.$langs->trans("OAUTH_ID").' ';
- print ' ';
+ print ' ';
print ' ';
// Api Secret
print '';
print ''.$langs->trans("OAUTH_SECRET").' ';
- print ' ';
+ print ' ';
print ' ';
+
+ // TODO Move this into token generation
+ if ($supported) {
+ if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
+ print '';
+ print ''.$langs->trans("Scopes").' ';
+ print '';
+ print ' ';
+ print ' ';
+ } else {
+ print '';
+ print ''.$langs->trans("Scopes").' ';
+ print '';
+ //print ' ';
+ print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
+ print ' ';
+ }
+ }
}
print '
'."\n";
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index b2830f95743..00daaf01e27 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -138,11 +138,17 @@ if (GETPOST('error')) {
if ($mode == 'setup' && $user->admin) {
print ''.$langs->trans("OAuthSetupForLogin")." \n";
- //var_dump($list);
+ // Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
- $listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
+ $listinsetup[] = array(
+ $provider.'_NAME',
+ $provider.'_ID',
+ $provider.'_SECRET',
+ $provider.'_URLAUTHORIZE', // For custom oauth links
+ $provider.'_SCOPE' // For custom oauth links
+ );
}
}
@@ -165,46 +171,39 @@ if ($mode == 'setup' && $user->admin) {
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
- // Define $shortscope, $urltorenew, $urltodelete, $urltocheckperms
+ $shortscope = $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
+ if (getDolGlobalString($key[4])) {
+ $shortscope = getDolGlobalString($key[4]);
+ }
+ $state = $shortscope; // TODO USe a better state
+
+ // Define $urltorenew, $urltodelete, $urltocheckperms
// TODO Use array $supportedoauth2array
if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
- $shortscope = 'user,public_repo';
- // Note: github does not accept csrf key inside the state parameter (only know values)
- $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ // Note: github does not accept csrf key inside the state parameter (only known values)
+ $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
} elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
// We pass this key list into the param 'state' because we need it before and after the redirect.
- $shortscope = 'userinfo_email,userinfo_profile';
- $shortscope .= ',openid,email,profile'; // For openid connect
- if (!empty($conf->printing->enabled)) {
- $shortscope .= ',cloud_print';
- }
- if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
- $shortscope .= ',admin_directory_user';
- }
- if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
- $shortscope.=',gmail_full';
- }
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
- $shortscope = 'none';
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
- $shortscope = 'none';
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltodelete = '';
+ $urltocheckperms = '';
+ } elseif ($keyforsupportedoauth2array = 'OAUTH_OTHER_NAME') {
+ $urltorenew = $urlwithroot.'/core/modules/oauth/generic_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} else {
@@ -212,7 +211,8 @@ if ($mode == 'setup' && $user->admin) {
$urltodelete = '';
$urltocheckperms = '';
}
- $urltorenew .= '&keyforprovider='.$keyforprovider;
+
+ $urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
// Show value of token
$tokenobj = null;
@@ -246,7 +246,7 @@ if ($mode == 'setup' && $user->admin) {
} elseif ($endoflife == $tokenobj::EOL_UNKNOWN) {
$expiredat = $langs->trans("Unknown");
} else {
- $expiredat = dol_print_date($endoflife, "dayhour");
+ $expiredat = dol_print_date($endoflife, "dayhour", 'tzuserrel');
}
}
}
@@ -260,10 +260,16 @@ if ($mode == 'setup' && $user->admin) {
print '';
print '
'."\n";
+ // Api Name
+ $label = $langs->trans($keyforsupportedoauth2array);
print '';
print '';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
- print $langs->trans($keyforsupportedoauth2array);
+ if ($label == $keyforsupportedoauth2array) {
+ print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+ } else {
+ print $label;
+ }
if ($keyforprovider) {
print ' ('.$keyforprovider.' )';
} else {
@@ -292,7 +298,8 @@ if ($mode == 'setup' && $user->admin) {
print '';
print ' ';
if (is_object($tokenobj)) {
- print $langs->trans("HasAccessToken");
+ // TODO Read in database to get the date of creation of token
+ print $form->textwithpicto(yn(1), $langs->trans("HasAccessToken").' : ');
} else {
print ''.$langs->trans("NoAccessToken").' ';
}
@@ -305,7 +312,9 @@ if ($mode == 'setup' && $user->admin) {
}
// Request remote token
if ($urltorenew) {
- print ''.$langs->trans('RequestAccess').' ';
+ print ''.$langs->trans('GetAccess').' ';
+ print $form->textwithpicto('', $langs->trans('RequestAccess'));
+ print ' ';
}
// Check remote access
if ($urltocheckperms) {
@@ -378,8 +387,8 @@ if ($mode == 'setup' && $user->admin) {
}
}
-
print '';
+ print ' ';
}
}
diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php
index 79190725c16..090e2254541 100644
--- a/htdocs/admin/security_other.php
+++ b/htdocs/admin/security_other.php
@@ -61,14 +61,17 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
dol_print_error($db);
}
} elseif ($action == 'updateform') {
- $res1 = 1; $res2 = 1;
+ $res1 = 1; $res2 = 1; $res3 = 1;
if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
$res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
$res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
}
- if ($res1 && $res2) {
+ if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
+ $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity);
+ }
+ if ($res1 && $res2 && $res3) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
}
@@ -174,6 +177,14 @@ print ' ';
print ' ';
+print '';
+print ''.$langs->trans("MaxNumberOfImagesInGetPost").' ';
+print ' ';
+print '';
+print ' '.strtolower($langs->trans("Images"));
+print ' ';
+print ' ';
+
/*
if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
$conf->global->MAIN_APPLICATION_TITLE = "";
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index a23f3127ca8..2b25d7deb5a 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -643,7 +643,7 @@ print ''."\n";
print '';
print ''.$langs->trans("MainDefaultWarehouse").' ';
print '';
-print $formproduct->selectWarehouses($conf->global->MAIN_DEFAULT_WAREHOUSE, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
+print $formproduct->selectWarehouses(!empty($conf->global->MAIN_DEFAULT_WAREHOUSE) ? $conf->global->MAIN_DEFAULT_WAREHOUSE : -1, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
print ' ';
print " ";
print " \n";
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index fae91d3ecb4..588cc5ed866 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -168,9 +168,10 @@ print '';
print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.' ';
print ' ';
print '';
-print '';
+print ' ';
print '';
+
print '';
print '';
@@ -195,27 +196,31 @@ print '';
print '';
print ' ';
-print '';
+print ' ';
-print ''.$langs->trans("ShowAdvancedOptions").' ';
+print '';
+print '';
+
+print '';
print '';
print '';
+print '
';
if (in_array($type, array('mysql', 'mysqli'))) {
print "\n";
print '
'.$langs->trans("MySqlExportParameters").' ';
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 763463d6fb8..c55db4ef2a1 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -203,25 +203,30 @@ if ($action == 'builddoc') {
$forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH);
$forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
- for ($i = 0; $i < $numberofsticker; $i++) {
- $arrayofrecords[] = array(
- 'textleft'=>$textleft,
- 'textheader'=>$textheader,
- 'textfooter'=>$textfooter,
- 'textright'=>$textright,
- 'code'=>$code,
- 'encoding'=>$encoding,
- 'is2d'=>$is2d,
- 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
- );
+ $MAXSTICKERS = 1000;
+ if ($numberofsticker <= $MAXSTICKERS) {
+ for ($i = 0; $i < $numberofsticker; $i++) {
+ $arrayofrecords[] = array(
+ 'textleft'=>$textleft,
+ 'textheader'=>$textheader,
+ 'textfooter'=>$textfooter,
+ 'textright'=>$textright,
+ 'code'=>$code,
+ 'encoding'=>$encoding,
+ 'is2d'=>$is2d,
+ 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
+ );
+ }
+ } else {
+ $mesg = $langs->trans("ErrorQuantityIsLimitedTo", $MAXSTICKERS);
+ $error++;
}
}
$i++;
- $mesg = '';
// Build and output PDF
- if ($mode == 'label') {
+ if (!$error && $mode == 'label') {
if (!count($arrayofrecords)) {
$mesg = $langs->trans("ErrorRecordNotFound");
}
@@ -240,7 +245,7 @@ if ($action == 'builddoc') {
}
}
- if ($result <= 0 || $mesg) {
+ if ($result <= 0 || $mesg || $error) {
if (empty($mesg)) {
$mesg = 'Error '.$result;
}
@@ -272,8 +277,6 @@ print ' ';
print ''.$langs->trans("PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv("BuildPageToPrint")).' ';
print ' ';
-dol_htmloutput_errors($mesg);
-
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").' ';
//print ' ';
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index fcac14f1337..0a618974024 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -305,7 +305,8 @@ class Categories extends DolibarrApi
Categorie::TYPE_CUSTOMER,
Categorie::TYPE_SUPPLIER,
Categorie::TYPE_MEMBER,
- Categorie::TYPE_PROJECT
+ Categorie::TYPE_PROJECT,
+ Categorie::TYPE_KNOWLEDGEMANAGEMENT
])) {
throw new RestException(401);
}
@@ -322,6 +323,8 @@ class Categories extends DolibarrApi
throw new RestException(401);
} elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
+ } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
+ throw new RestException(401);
}
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index bcfa5c541fd..8d26b5583d4 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -332,6 +332,7 @@ class Categorie extends CommonObject
// Check parameters
if (empty($id) && empty($label) && empty($ref_ext)) {
+ $this->error = "No category to search for";
return -1;
}
if (!is_null($type) && !is_numeric($type)) {
@@ -389,6 +390,7 @@ class Categorie extends CommonObject
return 1;
} else {
+ $this->error = "No category found";
return 0;
}
} else {
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 7e8a1252095..5405b33d994 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -103,7 +103,7 @@ if ($confirm == 'no') {
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Remove element from category
-if ($id > 0 && $removeelem > 0) {
+if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$tmpobject = new Product($db);
@@ -521,7 +521,8 @@ if ($type == Categorie::TYPE_PRODUCT) {
print ' ';
print ' ';
- $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
+ $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
@@ -544,7 +545,7 @@ if ($type == Categorie::TYPE_PRODUCT) {
// Link to delete from category
print '';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$prod->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$prod->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -597,7 +598,8 @@ if ($type == Categorie::TYPE_CUSTOMER) {
print ' ';
print ' ';
- $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
+ $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print ''."\n";
@@ -618,7 +620,7 @@ if ($type == Categorie::TYPE_CUSTOMER) {
// Link to delete from category
print '';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$soc->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -671,7 +673,8 @@ if ($type == Categorie::TYPE_SUPPLIER) {
print ' ';
print ' ';
- $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
+ $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print ''."\n";
@@ -692,7 +695,7 @@ if ($type == Categorie::TYPE_SUPPLIER) {
// Link to delete from category
print '';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$soc->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -748,7 +751,8 @@ if ($type == Categorie::TYPE_MEMBER) {
print ' ';
print ' ';
- $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
+ $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->adherent->creer);
print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
print "\n";
@@ -772,7 +776,7 @@ if ($type == Categorie::TYPE_MEMBER) {
// Link to delete from category
print '';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$member->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$member->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -788,7 +792,7 @@ if ($type == Categorie::TYPE_MEMBER) {
}
}
-// Categorie contact
+// List of contacts
if ($type == Categorie::TYPE_CONTACT) {
$permission = $user->rights->societe->creer;
@@ -808,7 +812,7 @@ if ($type == Categorie::TYPE_CONTACT) {
print ' ';
print '';
print '';
- print $langs->trans("AddContactIntoCategory").' ';
+ print $langs->trans("AssignCategoryTo").' ';
print $form->selectContacts('', '', 'elemid');
print ' ';
print ' ';
@@ -826,7 +830,7 @@ if ($type == Categorie::TYPE_CONTACT) {
$param = '&limit='.$limit.'&id='.$id.'&type='.$type;
$num = count($contacts);
$nbtotalofrecords = '';
- $newcardbutton = '';
+ $newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
$objsoc = new Societe($db);
print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
@@ -853,7 +857,7 @@ if ($type == Categorie::TYPE_CONTACT) {
// Link to delete from category
print '';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$contact->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$contact->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -931,7 +935,7 @@ if ($type == Categorie::TYPE_ACCOUNT) {
// Link to delete from category
print ' ';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$account->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$account->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -1009,7 +1013,7 @@ if ($type == Categorie::TYPE_PROJECT) {
// Link to delete from category
print ' ';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$project->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -1026,7 +1030,7 @@ if ($type == Categorie::TYPE_PROJECT) {
}
// List of users
-if ($type == Categorie::TYPE_USER) {
+if ($type == Categorie::TYPE_USER && $user->hasRight("user", "user", "read")) {
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$users = $object->getObjectsInCateg($type);
@@ -1081,7 +1085,7 @@ if ($type == Categorie::TYPE_USER) {
// Link to delete from category
print ' ';
if ($user->rights->user->user->creer) {
- print "id."&type=".$type."&removeelem=".$userentry->id."'>";
+ print " id."&type=".$type."&action=unlink&token=".newToken()."&removeelem=".$userentry->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -1095,6 +1099,9 @@ if ($type == Categorie::TYPE_USER) {
print ''."\n";
}
+} else {
+ print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user');
+ accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0);
}
@@ -1140,7 +1147,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
// Link to delete from category
print ' ';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$project->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
@@ -1156,6 +1163,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
}
}
+// List of tickets
if ($type == Categorie::TYPE_TICKET) {
$permission = ($user->rights->categorie->creer || $user->rights->categorie->creer);
@@ -1212,7 +1220,7 @@ if ($type == Categorie::TYPE_TICKET) {
// Link to delete from category
print ' ';
if ($permission) {
- print "id."&type=".$typeid."&removeelem=".$ticket->id."'>";
+ print " id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$ticket->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print " ";
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index ed25d89db67..6f97b3f134d 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -538,7 +538,7 @@ if (empty($reshook) && $action == 'add') {
$error++;
}
// End date
- $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth", 'int') ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
+ $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
// Set date of end of event
$deltatime = num_between_day($object->datep, $datep);
$datef = dol_time_plus_duree($datef, $deltatime, 'd');
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index d2b089491a7..db62dfe6a9f 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -216,6 +216,9 @@ class CActionComm
if ($obj->module == 'shipping' && !empty($conf->expedition->enabled) && !empty($user->rights->expedition->lire)) {
$qualified = 1;
}
+ if (preg_split("/@/", $obj->module, -1)[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
+ $qualified = 1;
+ }
// For the generic case with type = 'module...' and module = 'myobject@mymodule'
$regs = array();
if (preg_match('/^module/', $obj->type)) {
diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php
index 8da9a17ebb2..0e582946df9 100644
--- a/htdocs/comm/multiprix.php
+++ b/htdocs/comm/multiprix.php
@@ -75,7 +75,7 @@ if ($_socid > 0) {
// We load data of thirdparty
$objsoc = new Societe($db);
$objsoc->id = $_socid;
- $objsoc->fetch($_socid, $to);
+ $objsoc->fetch($_socid);
$head = societe_prepare_head($objsoc);
@@ -141,7 +141,6 @@ if ($_socid > 0) {
$resql = $db->query($sql);
if ($resql) {
print '';
- $tag = !$tag;
print '';
print ''.$langs->trans("Date").' ';
print ''.$langs->trans("PriceLevel").' ';
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 06c36ce517c..31e318f0c39 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -112,17 +112,17 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('propalcard', 'globalcard'));
-$usercanread = $user->rights->propal->lire;
-$usercancreate = $user->rights->propal->creer;
-$usercandelete = $user->rights->propal->supprimer;
+$usercanread = $user->hasRight("propal", "lire");
+$usercancreate = $user->hasRight("propal", "creer");
+$usercandelete = $user->hasRight("propal", "supprimer");
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
-$usercancreateorder = $user->rights->commande->creer;
-$usercancreateinvoice = $user->rights->facture->creer;
-$usercancreatecontract = $user->rights->contrat->creer;
+$usercancreateorder = $user->hasRight('commande', 'creer');
+$usercancreateinvoice = $user->hasRight('facture', 'creer');
+$usercancreatecontract = $user->hasRight('contrat', 'creer');
$usercancreateintervention = $user->hasRight('ficheinter', 'creer');
$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer'));
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index aa26e7be794..43c49bdc8a2 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -108,9 +108,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
-$usercanread = $user->hasRight('commande', 'lire');
-$usercancreate = $user->hasRight('commande', 'creer');
-$usercandelete = $user->hasRight('commande', 'supprimer');
+$usercanread = $user->hasRight("commande", "lire");
+$usercancreate = $user->hasRight("commande", "creer");
+$usercandelete = $user->hasRight("commande", "supprimer");
// Advanced permissions
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'close'))));
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index 2751947c023..3dfe18a3581 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -846,6 +846,9 @@ if ($action == 'create') {
$object = new Account($db);
$object->fetch(GETPOST('id', 'int'));
+ $title = $object->ref." - ".$langs->trans("Card");
+ llxHeader("", $title, $help_url);
+
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
if ($conf->use_javascript_ajax) {
@@ -1014,7 +1017,7 @@ if ($action == 'create') {
$tdextra = ' class="fieldrequired titlefieldcreate"';
}
- print ' '.$langs->trans("AccountancyCode").' ';
+ print ''.$langs->trans("AccountancyCode").' ';
print '';
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 2dbaaa07373..c08336841e2 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -387,6 +387,10 @@ if (empty($numref)) {
* Show list of record into a bank statement
*/
+ $title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements");
+ $helpurl = "";
+ llxHeader('', $title, $helpurl);
+
// Onglets
$head = account_statement_prepare_head($object, $numref);
print dol_get_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 59345604d1d..61b0c4b6302 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -128,11 +128,11 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicecard', 'globalcard'));
-$usercanread = $user->rights->facture->lire;
-$usercancreate = $user->rights->facture->creer;
-$usercanissuepayment = $user->rights->facture->paiement;
-$usercandelete = $user->rights->facture->supprimer;
-$usercancreatecontract = $user->rights->contrat->creer;
+$usercanread = $user->hasRight("facture", "lire");
+$usercancreate = $user->hasRight("facture", "creer");
+$usercanissuepayment = $user->hasRight("facture", "paiement");
+$usercandelete = $user->hasRight("facture", "supprimer");
+$usercancreatecontract = $user->hasRight("contrat", "creer");
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index bdc6a102147..23f53c3d405 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -363,11 +363,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_datelimit_start = '';
$search_datelimit_end = '';
$search_fac_rec_source_title = '';
- $option = '';
- $filter = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
+ $option = '';
+ $socid = 0;
}
if (empty($reshook)) {
@@ -919,7 +919,7 @@ if ($resql) {
llxHeader('', $langs->trans('CustomersInvoices'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
- if ($socid) {
+ if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_company)) {
@@ -1151,8 +1151,9 @@ if ($resql) {
print ' ';
print ' ';
print ' ';
+ print ' ';
- print_barre_liste($langs->trans('BillsCustomers').' '.($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
+ print_barre_liste($langs->trans('BillsCustomers').' '.($socid > 0 ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
$topicmail = "SendBillRef";
$modelmail = "facture_send";
@@ -1329,7 +1330,7 @@ if ($resql) {
}
// Thirdparty
if (!empty($arrayfields['s.nom']['checked'])) {
- print ' ';
+ print ' 0 ? " disabled" : "").'> ';
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
@@ -2083,7 +2084,7 @@ if ($resql) {
// Amount HT
if (!empty($arrayfields['f.total_ht']['checked'])) {
- print ''.price($obj->total_ht)." \n";
+ print ''.price($obj->total_ht)." \n";
if (!$i) {
$totalarray['nbfield']++;
}
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index e7cb0b1d4b5..55ee99f4cb6 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -102,19 +102,24 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill');
print '';
-print getNumberInvoicesPieChart('customers');
-print ' ';
+if (isModEnabled('facture')) {
+ print getNumberInvoicesPieChart('customers');
+ print ' ';
+}
-if (!empty($conf->fournisseur->enabled)) {
+if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) {
print getNumberInvoicesPieChart('fourn');
print ' ';
}
-print getCustomerInvoiceDraftTable($max, $socid);
-
-if (!empty($conf->fournisseur->enabled)) {
+if (isModEnabled('facture')) {
+ print getCustomerInvoiceDraftTable($max, $socid);
print ' ';
+}
+
+if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) {
print getDraftSupplierTable($max, $socid);
+ print ' ';
}
print '
';
@@ -273,7 +278,7 @@ if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
// Last modified supplier invoices
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
+if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) {
$langs->load("boxes");
$facstatic = new FactureFournisseur($db);
@@ -400,7 +405,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
// Latest donations
-if (!empty($conf->don->enabled) && !empty($user->rights->don->lire)) {
+if (isModEnabled('don') && !empty($user->rights->don->lire)) {
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$langs->load("boxes");
@@ -490,7 +495,7 @@ if (!empty($conf->don->enabled) && !empty($user->rights->don->lire)) {
/**
* Social contributions to pay
*/
-if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) {
+if (isModEnabled('tax') && !empty($user->rights->tax->charges->lire)) {
if (!$socid) {
$chargestatic = new ChargeSociales($db);
@@ -582,7 +587,7 @@ if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) {
/*
* Customers orders to be billed
*/
-if (isModEnabled('facture') && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
+if (isModEnabled('facture') && isModEnabled('commande') && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
$commandestatic = new Commande($db);
$langs->load("orders");
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 8c859e6e689..f41ecd820ad 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -59,8 +59,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
-
-$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
+// filter by dates from / to
+$search_date_start_day = GETPOST('search_date_start_day', 'int');
+$search_date_start_month = GETPOST('search_date_start_month', 'int');
+$search_date_start_year = GETPOST('search_date_start_year', 'int');
+$search_date_end_day = GETPOST('search_date_end_day', 'int');
+$search_date_end_month = GETPOST('search_date_end_month', 'int');
+$search_date_end_year = GETPOST('search_date_end_year', 'int');
+$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
+$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
$filteraccountid = GETPOST('accountid', 'int');
// Security check
@@ -265,7 +272,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
*/
if (GETPOST('removefilter')) {
- $filterdate = '';
+ // filter by dates from / to
+ $search_date_start_day = '';
+ $search_date_start_month = '';
+ $search_date_start_year = '';
+ $search_date_end_day = '';
+ $search_date_end_month = '';
+ $search_date_end_year = '';
+ $search_date_start = '';
+ $search_date_end = '';
$filteraccountid = 0;
}
@@ -352,7 +367,13 @@ if ($action == 'new') {
//print '
'.$langs->trans('Date').' '.dol_print_date($now,'day').' ';
// Filter
print '
'.$langs->trans("DateChequeReceived").' ';
- print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
+ // filter by dates from / to
+ print '';
+ print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print '
';
print ' ';
print '
'.$langs->trans("BankAccount").' ';
$form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
@@ -363,7 +384,7 @@ if ($action == 'new') {
print '';
print '
';
- if ($filterdate || $filteraccountid > 0) {
+ if ($search_date_start || $search_date_end || $filteraccountid > 0) {
print ' ';
print '
';
}
@@ -382,8 +403,11 @@ if ($action == 'new') {
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_bordereau = 0";
$sql .= " AND b.amount > 0";
- if ($filterdate) {
- $sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
+ if ($search_date_start) {
+ $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
+ }
+ if ($search_date_end) {
+ $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
}
if ($filteraccountid > 0) {
$sql .= " AND ba.rowid = ".((int) $filteraccountid);
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 487576ed058..b58ac33707e 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -185,7 +185,7 @@ $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62';
// values using a ",". In this case, Dolibarr will check login/pass for each value in
// order defined into value. However, note that this can't work with all values.
// Examples:
-// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user record.
+// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user file (default).
// $dolibarr_main_authentication='http'; // Use the HTTP Basic authentication
// $dolibarr_main_authentication='ldap'; // Check the password into a LDAP server
// $dolibarr_main_authentication='ldap,dolibarr'; // You can set several mode using a comma as a separator.
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 8d60b37611f..a0091061adb 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -207,16 +207,16 @@ foreach ($object->fields as $key => $val) {
}
// Add none object fields to fields for list
-$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>22, 'checked'=>0);
+$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0);
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
- $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>25, 'checked'=>1);
+ $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1);
}
$arrayfields['unsubscribed'] = array(
'label'=>'No_Email',
'checked'=>0,
'enabled'=>(!empty($conf->mailing->enabled)),
- 'position'=>41);
+ 'position'=>111);
if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index f0ef66eb78b..3749b403469 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -361,7 +361,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
}
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
- if ($mailfile->error) {
+ if (!empty($mailfile->error) || !empty($mailfile->errors)) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = 'presend';
} else {
@@ -427,9 +427,14 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
} else {
$langs->load("other");
$mesg = '
';
- if ($mailfile->error) {
+ if (!empty($mailfile->error) || !empty($mailfile->errors)) {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
- $mesg .= ' '.$mailfile->error;
+ if (!empty($mailfile->error)) {
+ $mesg .= ' '.$mailfile->error;
+ }
+ if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
+ $mesg .= ' '.implode(' ', $mailfile->errors);
+ }
} else {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php
index 090fc52cb4f..54e3e1e4470 100644
--- a/htdocs/core/ajax/selectsearchbox.php
+++ b/htdocs/core/ajax/selectsearchbox.php
@@ -64,11 +64,11 @@ $arrayresult = array();
// Define $searchform
-if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) {
+if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->hasRight('adherent', 'lire')) {
$arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) {
+if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) {
$arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
@@ -76,7 +76,7 @@ if (isModEnabled('societe') && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISA
$arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (((!empty($conf->product->enabled) && $user->hasRight('produit', 'lire')) || (!empty($conf->service->enabled) && $user->hasRight('service', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
+if (((isModEnabled('product') && $user->hasRight('produit', 'lire')) || (isModEnabled('service') && $user->hasRight('service', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
$arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
// search on lot/serial numbers
if (isModEnabled('productbatch')) {
@@ -108,13 +108,13 @@ if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INV
$arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) {
+if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->hasRight('supplier_proposal', 'lire')) {
$arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) {
+if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) {
$arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
-if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
+if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
$arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
@@ -129,7 +129,7 @@ if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INV
}
// Vendor payments
-if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
+if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
$arrayresult['searchintovendorpayments'] = array(
'position'=>175,
'img'=>'object_payment',
@@ -139,7 +139,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S
}
// Miscellaneous payments
-if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) {
+if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->hasRight('banque', 'lire')) {
$arrayresult['searchintomiscpayments'] = array(
'position'=>180,
'img'=>'object_payment',
@@ -148,24 +148,24 @@ if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS
'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('contrat') && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) {
+if (isModEnabled('contrat') && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->hasRight('contrat', 'lire')) {
$arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('ficheinter') && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) {
+if (isModEnabled('ficheinter') && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->hasRight('ficheinter', 'lire')) {
$arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('ticket') && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) {
+if (isModEnabled('ticket') && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->hasRight('ticket', 'read')) {
$arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// HR
-if (isModEnabled('user') && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) {
+if (isModEnabled('user') && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->hasRight('user', 'user', 'lire')) {
$arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('expensereport') && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) {
+if (isModEnabled('expensereport') && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->hasRight('expensereport', 'lire')) {
$arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
-if (isModEnabled('holiday') && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) {
+if (isModEnabled('holiday') && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->hasRight('holiday', 'read')) {
$arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php
index 9462c810393..6aec6f4064a 100644
--- a/htdocs/core/boxes/box_birthdays.php
+++ b/htdocs/core/boxes/box_birthdays.php
@@ -85,13 +85,19 @@ class box_birthdays extends ModeleBoxes
if ($user->rights->user->user->lire) {
$tmparray = dol_getdate(dol_now(), true);
- $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status";
+ $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, 'birth' as typea, u.email, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
- $sql .= " ORDER BY DAY(u.birth) ASC";
- $sql .= $this->db->plimit($max, 0);
+ $sql .= ' UNION ';
+ $sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, 'employment' as typea, u.email, u.statut as status";
+ $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+ $sql .= " WHERE u.entity IN (".getEntity('user').")";
+ $sql .= " AND u.statut = 1";
+ $sql .= dolSqlDateFilter('u.dateemployment', 0, $tmparray['mon'], 0);
+
+ $sql .= " ORDER BY DAY(datea) ASC";
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -108,9 +114,13 @@ class box_birthdays extends ModeleBoxes
$userstatic->email = $objp->email;
$userstatic->statut = $objp->status;
- $dateb = $this->db->jdate($objp->birth);
+ $dateb = $this->db->jdate($objp->datea);
$age = date('Y', dol_now()) - date('Y', $dateb);
+ $picb = ' ';
+ $pice = ' ';
+ $typea = ($objp->typea == 'birth') ? $picb : $pice;
+
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $userstatic->getNomUrl(1),
@@ -119,7 +129,18 @@ class box_birthdays extends ModeleBoxes
$this->info_box_contents[$line][] = array(
'td' => 'class="center nowraponall"',
- 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears')
+ 'text' => dol_print_date($dateb, "day", 'tzserver')
+ );
+
+ $this->info_box_contents[$line][] = array(
+ 'td' => 'class="right nowraponall"',
+ 'text' => $age.' '.$langs->trans('DurationYears')
+ );
+
+ $this->info_box_contents[$line][] = array(
+ 'td' => 'class="center nowraponall"',
+ 'text' => $typea,
+ 'asis' => 1
);
/*$this->info_box_contents[$line][] = array(
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 94fb05d5346..54573f92c7a 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2003 Jean-Louis Bergamo
* Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2019-2020 Frédéric France
+ * Copyright (C) 2019-2022 Frédéric France
*
* 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
@@ -30,6 +30,7 @@
* \brief File of class to send emails (with attachments or not)
*/
+use OAuth\Common\Storage\DoliStorage;
/**
* Class to send emails (with attachments or not)
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto);
@@ -71,9 +72,29 @@ class CMailFile
*/
public $error = '';
+ /**
+ * @var string[] Array of Error code (or message)
+ */
+ public $errors = array();
+
public $smtps; // Contains SMTPs object (if this method is used)
public $phpmailer; // Contains PHPMailer object (if this method is used)
+ /**
+ * @var Swift_SmtpTransport
+ */
+ public $transport;
+
+ /**
+ * @var Swift_Mailer
+ */
+ public $mailer;
+
+ /**
+ * @var Swift_Plugins_Loggers_ArrayLogger
+ */
+ public $logger;
+
/**
* @var string CSS
*/
@@ -470,12 +491,12 @@ class CMailFile
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
$adressEmailFrom = reset($adressEmailFrom);
if ($emailMatchs !== false && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom) {
- $result = $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
+ $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
} else {
- $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
+ $this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} else {
- $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
+ $this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
@@ -485,7 +506,7 @@ class CMailFile
// Set the To addresses with an associative array
if (!empty($this->addr_to)) {
try {
- $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
+ $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -493,14 +514,14 @@ class CMailFile
if (!empty($this->reply_to)) {
try {
- $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
+ $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
try {
- $result = $this->message->setCharSet($conf->file->character_set_client);
+ $this->message->setCharSet($conf->file->character_set_client);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -547,14 +568,26 @@ class CMailFile
}
if (!empty($this->addr_cc)) {
- $this->message->setCc($this->getArrayAddress($this->addr_cc));
+ try {
+ $this->message->setCc($this->getArrayAddress($this->addr_cc));
+ } catch (Exception $e) {
+ $this->errors[] = $e->getMessage();
+ }
}
if (!empty($this->addr_bcc)) {
- $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
+ try {
+ $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
+ } catch (Exception $e) {
+ $this->errors[] = $e->getMessage();
+ }
}
//if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) {
- $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
+ try {
+ $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
+ } catch (Exception $e) {
+ $this->errors[] = $e->getMessage();
+ }
}
} else {
// Send mail method not correctly defined
@@ -657,6 +690,8 @@ class CMailFile
}
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
+ $keyforsmtpauthtype = "MAIN_MAIL_SMTPS_AUTH_TYPE";
+ $keyforsmtpoauthservice = "MAIN_MAIL_SMTPS_OAUTH_SERVICE";
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
@@ -832,6 +867,36 @@ class CMailFile
$this->smtps->setPW($loginpass);
}
+ if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
+ $keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice;
+ if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
+ $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
+ } else {
+ $keyforprovider = '';
+ }
+ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
+ $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
+
+ $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
+
+ require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+
+ $storage = new DoliStorage($db, $conf);
+ try {
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ if (is_object($tokenobj)) {
+ $this->smtps->setToken($tokenobj->getAccessToken());
+ } else {
+ $this->error = "Token not found";
+ }
+ } catch (Exception $e) {
+ // Return an error if token not found
+ $this->error = $e->getMessage();
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
+ }
+ }
+
$res = true;
$from = $this->smtps->getFrom('org');
if ($res && !$from) {
@@ -852,7 +917,6 @@ class CMailFile
}
$result = $this->smtps->sendMsg();
- //print $result;
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
@@ -898,9 +962,39 @@ class CMailFile
if (!empty($conf->global->$keyforsmtpid)) {
$this->transport->setUsername($conf->global->$keyforsmtpid);
}
- if (!empty($conf->global->$keyforsmtppw)) {
+ if (!empty($conf->global->$keyforsmtppw) && getDolGlobalString($keyforsmtpauthtype) != "XOAUTH2") {
$this->transport->setPassword($conf->global->$keyforsmtppw);
}
+ if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
+ $keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice);
+ if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
+ $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
+ } else {
+ $keyforprovider = '';
+ }
+ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
+ $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
+
+ $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
+
+ require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+
+ $storage = new DoliStorage($db, $conf);
+ try {
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ if (is_object($tokenobj)) {
+ $this->transport->setAuthMode('XOAUTH2');
+ $this->transport->setPassword($tokenobj->getAccessToken());
+ } else {
+ $this->errors[] = "Token not found";
+ }
+ } catch (Exception $e) {
+ // Return an error if token not found
+ $this->errors[] = $e->getMessage();
+ dol_syslog("CMailFile::sendfile: mail end error=".$e->getMessage(), LOG_ERR);
+ }
+ }
if (!empty($conf->global->$keyforsslseflsigned)) {
$this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));
}
@@ -933,16 +1027,16 @@ class CMailFile
try {
$result = $this->mailer->send($this->message, $failedRecipients);
} catch (Exception $e) {
- $this->error = $e->getMessage();
+ $this->errors[] = $e->getMessage();
}
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
}
$res = true;
- if (!empty($this->error) || !$result) {
+ if (!empty($this->error) || !empty($this->errors) || !$result) {
if (!empty($failedRecipients)) {
- $this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
+ $this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
}
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 2d393ab9dc3..6d460dfadf0 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -744,6 +744,7 @@ abstract class CommonObject
public function setUpperOrLowerCase()
{
global $conf;
+
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
@@ -759,8 +760,12 @@ abstract class CommonObject
$this->address = dol_strtoupper($this->address);
$this->town = dol_strtoupper($this->town);
}
- $this->email = dol_strtolower($this->email);
- $this->personal_email = dol_strtolower($this->personal_email);
+ if (isset($this->email)) {
+ $this->email = dol_strtolower($this->email);
+ }
+ if (isset($this->personal_email)) {
+ $this->personal_email = dol_strtolower($this->personal_email);
+ }
}
/**
@@ -6019,7 +6024,7 @@ abstract class CommonObject
// Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine)
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && !is_int($key)) {
// we can add this attribute to object
- if (!empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
+ if (!empty($extrafields->attributes[$this->table_element]) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
$this->array_options["options_".$key] = $this->db->jdate($value);
} else {
@@ -6032,7 +6037,7 @@ abstract class CommonObject
// If field is a computed field, value must become result of compute
foreach ($tab as $key => $value) {
- if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
+ if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
//var_dump($conf->disable_compute);
if (empty($conf->disable_compute)) {
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
@@ -7760,12 +7765,12 @@ abstract class CommonObject
} else {
$value = '';
}
- } elseif (preg_match('/^(text|html)/', $type)) {
- $value = dol_htmlentitiesbr($value);
} elseif ($type == 'password') {
$value = preg_replace('/./i', '*', $value);
} elseif ($type == 'array') {
$value = implode(' ', $value);
+ } else { // text|html|varchar
+ $value = dol_htmlentitiesbr($value);
}
//print $type.'-'.$size.'-'.$value;
@@ -8446,8 +8451,8 @@ abstract class CommonObject
/**
* Get buy price to use for margin calculation. This function is called when buy price is unknown.
* Set buy price = sell price if ForceBuyingPriceIfNull configured,
- * else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice
- * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice
+ * elseif calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice
+ * elseif calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice
* else set min buy price as buy price
*
* @param float $unitPrice Product unit price
@@ -8801,7 +8806,7 @@ abstract class CommonObject
public function isInt($info)
{
if (is_array($info)) {
- if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) {
+ if (isset($info['type']) && (preg_match('/(^int|int$)/i', $info['type']))) {
return true;
} else {
return false;
@@ -9060,6 +9065,8 @@ abstract class CommonObject
return 'NULL';
} elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) {
return price2num("$value");
+ } elseif (preg_match('/int$/i', $fieldsentry['type'])) {
+ return (int) $value;
} elseif ($fieldsentry['type'] == 'boolean') {
if ($value) {
return 'true';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 82e73186233..17b8c50aff3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5156,8 +5156,9 @@ class Form
closeOnEscape: false,
buttons: {
"'.dol_escape_js($langs->transnoentities($labelbuttonyes)).'": function() {
- var options = "&token='.urlencode(newToken()).'";
+ var options = "token='.urlencode(newToken()).'";
var inputok = '.json_encode($inputok).'; /* List of fields into form */
+ var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'";
if (inputok.length>0) {
$.each(inputok, function(i, inputname) {
@@ -5174,13 +5175,19 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
- var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
- if (pageyes.length > 0) { location.href = urljump; }
+ if (pageyes.length > 0) {
+ var post = $.post(
+ pageyes,
+ options,
+ (data) => {$("body").html(data)}
+ );
+ }
$(this).dialog("close");
},
"'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() {
- var options = "&token='.urlencode(newToken()).'";
+ var options = "token='.urlencode(newToken()).'";
var inputko = '.json_encode($inputko).'; /* List of fields into form */
+ var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'";
if (inputko.length>0) {
$.each(inputko, function(i, inputname) {
@@ -5191,9 +5198,13 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
- var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
- //alert(urljump);
- if (pageno.length > 0) { location.href = urljump; }
+ if (pageno.length > 0) {
+ var post = $.post(
+ pageno,
+ options,
+ (data) => {$("body").html(data)}
+ );
+ }
$(this).dialog("close");
}
}
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 4c77566eeed..61f62f28a54 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -4,7 +4,7 @@
* Copyright (C) 2010-2011 Juanjo Menent
* Copyright (C) 2015-2017 Marcos García
* Copyright (C) 2015-2017 Nicolas ZABOURI
- * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2018-2022 Frédéric France
* Copyright (C) 2022 Charlene Benke
*
* This program is free software; you can redistribute it and/or modify
@@ -85,7 +85,7 @@ class FormMail extends Form
public $toid;
/**
- * @var string replyto name
+ * @var string Reply-to name
*/
public $replytoname;
@@ -95,20 +95,25 @@ class FormMail extends Form
public $replytomail;
/**
- * @var string to name
+ * @var string To name
*/
public $toname;
/**
- * @var string to email
+ * @var string To email
*/
public $tomail;
/**
- * @var string trackid
+ * @var string Track id
*/
public $trackid;
+ /**
+ * @var string If you know a MSGID of an email and want to send the email in reply to it. Will be added into header as In-Reply-To: <...>
+ */
+ public $inreplyto;
+
public $withsubstit; // Show substitution array
public $withfrom;
@@ -396,7 +401,7 @@ class FormMail extends Form
// Define output language
$outputlangs = $langs;
$newlang = '';
- if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && !empty($this->param['langsmodels'])) {
$newlang = $this->param['langsmodels'];
}
if (!empty($newlang)) {
@@ -423,7 +428,7 @@ class FormMail extends Form
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
- if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) {
+ if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) {
foreach ($this->param['fileinit'] as $file) {
$this->add_attached_files($file, basename($file), dol_mimetype($file));
}
@@ -449,6 +454,7 @@ class FormMail extends Form
$out .= ' ';
$out .= ' ';
$out .= ' ';
+ $out .= ' ';
}
if (!empty($this->withfrom)) {
if (!empty($this->withfromreadonly)) {
@@ -458,7 +464,7 @@ class FormMail extends Form
}
foreach ($this->param as $key => $value) {
if (is_array($value)) {
- $out .= "\n";
+ $out .= "\n";
} else {
$out .= ' '."\n";
}
@@ -598,7 +604,7 @@ class FormMail extends Form
// Also add robot email
if (!empty($this->fromalsorobot)) {
- if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) {
+ if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && getDolGlobalString('MAIN_MAIL_EMAIL_FROM') != getDolGlobalString('MAIN_INFO_SOCIETE_MAIL')) {
$liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($this->frommail) {
$liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
@@ -1176,7 +1182,7 @@ class FormMail extends Form
{
global $conf, $langs;
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
- $errorstomail = (!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
+ $errorstomail = getDolGlobalString('MAIN_MAIL_ERRORS_TO', (!empty($this->errorstomail) ? $this->errorstomail : ''));
if ($this->witherrorstoreadonly) {
$out = ''.$langs->trans("MailErrorsTo").' ';
$out .= ' ';
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 2dd729df91d..3ff36b356da 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -1093,6 +1093,7 @@ class FormSetupItem
$out.= $this->langs->trans("NorProspectNorCustomer");
}
} elseif ($this->type == 'product') {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$resprod = $product->fetch($this->fieldValue);
if ($resprod > 0) {
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index e13aaba4685..68cb3d1af84 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -119,7 +119,7 @@ class FormTicket
$this->action = 'add';
- $this->withcompany = $conf->societe->enabled ? 1 : 0;
+ $this->withcompany = isModEnabled("societe");
$this->withfromsocid = 0;
$this->withfromcontactid = 0;
//$this->withreadid=0;
@@ -169,7 +169,7 @@ class FormTicket
print dol_get_fiche_head(null, 'card', '', 0, '');
}
- print ' ';
// Severity
print ''.$langs->trans("TicketSeverity").' ';
- $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 0);
+ $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1);
print ' ';
// Subject
@@ -341,10 +341,12 @@ class FormTicket
print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
print '
';
} else {
- if ($this->withreadid > 0) {
+ if (isset($this->withreadid) && $this->withreadid > 0) {
$subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title.'';
+ } else {
+ $subject = GETPOST('subject', 'alpha');
}
- print '
';
+ print '
';
print '
';
}
}
@@ -643,7 +645,7 @@ class FormTicket
print ' ';
- print $form->buttonsSaveCancel((($this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
+ print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
/*
print '';
@@ -733,6 +735,7 @@ class FormTicket
}
print '>';
+
$value = ' ';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
@@ -744,7 +747,7 @@ class FormTicket
$value = $arraytypes['code'];
}
- print $value;
+ print $value ? $value : ' ';
print '';
}
}
@@ -839,6 +842,7 @@ class FormTicket
print '>';
+ $value = '';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
}
@@ -1172,6 +1176,8 @@ class FormTicket
}
print '>';
+
+ $value = '';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
}
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index 1f5a48a517d..06ada5c4911 100644
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -68,6 +68,11 @@ class SMTPs
*/
private $_smtpsPW = null;
+ /**
+ * Token in case we use OAUTH2
+ */
+ private $_smtpsToken = null;
+
/**
* Who sent the Message
* This can be defined via a INI file or via a setter method
@@ -565,13 +570,13 @@ class SMTPs
}
// Default authentication method is LOGIN
- if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) {
- $conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN';
+ if (empty($conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE)) {
+ $conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE = 'LOGIN';
}
// Send Authentication to Server
// Check for errors along the way
- switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {
+ switch ($conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE) {
case 'NONE':
// Do not send the 'AUTH type' message. For test purpose, if you don't need authentication, it is better to not enter login/pass into setup.
$_retVal = true;
@@ -583,9 +588,10 @@ class SMTPs
break;
case 'XOAUTH2':
// "user=$email\1auth=Bearer $token\1\1"
- $token = 'xxx';
- $xxxx = "user=".$this->_smtpsID."\1auth=Bearer ".$token."\1\1";
- $_retVal = $this->socket_send_str('AUTH XOAUTH2 '.base64_encode($xxxx), '235');
+ $user = $this->_smtpsID;
+ $token = $this->_smtpsToken;
+ $initRes = "user=".$user."\001auth=Bearer ".$token."\001\001";
+ $_retVal = $this->socket_send_str('AUTH XOAUTH2 '.base64_encode($initRes), '235');
if (!$_retVal) {
$this->_setErr(130, 'Error when asking for AUTH XOAUTH2');
}
@@ -631,7 +637,7 @@ class SMTPs
// Connect to Server
if ($this->socket = $this->_server_connect()) {
// If a User ID *and* a password is given, assume Authentication is desired
- if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) {
+ if (!empty($this->_smtpsID) && (!empty($this->_smtpsPW) || !empty($this->_smtpsToken))) {
// Send the RFC2554 specified EHLO.
$_retVal = $this->_server_authenticate();
} else {
@@ -923,6 +929,27 @@ class SMTPs
return $this->_smtpsPW;
}
+ /**
+ * User token for OAUTH2
+ *
+ * @param string $_strToken User token
+ * @return void
+ */
+ public function setToken($_strToken)
+ {
+ $this->_smtpsToken = $_strToken;
+ }
+
+ /**
+ * Retrieves the User token for OAUTH2
+ *
+ * @return string User token for OAUTH2
+ */
+ public function getToken()
+ {
+ return $this->_smtpsToken;
+ }
+
/**
* Character set used for current message
* Character set is defaulted to 'iso-8859-1';
@@ -1866,7 +1893,7 @@ class SMTPs
}
if (!(substr($server_response, 0, 3) == $response)) {
- $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
+ $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse:".$server_response);
$_retVal = false;
}
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index c11f94fa047..29db15e0a0b 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -637,7 +637,11 @@ class Translate
);
if (strpos($key, 'Format') !== 0) {
- $str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
+ try {
+ $str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
+ } catch (Exception $e) {
+ // No exception managed
+ }
}
// Crypt string into HTML
diff --git a/htdocs/core/class/utils_diff.class.php b/htdocs/core/class/utils_diff.class.php
index 9abc1d899fe..2925bffc3b6 100644
--- a/htdocs/core/class/utils_diff.class.php
+++ b/htdocs/core/class/utils_diff.class.php
@@ -247,6 +247,7 @@ class Diff
$html = '';
// loop over the lines in the diff
+ $element = 'unknown';
foreach ($diff as $line) {
// extend the HTML with the line
switch ($line[1]) {
@@ -260,10 +261,7 @@ class Diff
$element = 'ins';
break;
}
- $html .=
- '<'.$element.'>'
- . htmlspecialchars($line[0])
- . ''.$element.'>';
+ $html .= '<'.$element.'>'.dol_escape_htmltag($line[0]).''.$element.'>';
// extend the HTML with the separator
$html .= $separator;
@@ -286,6 +284,8 @@ class Diff
// initialise the HTML
$html = $indentation."
\n";
+ $rightCell = $leftCell = '';
+
// loop over the lines in the diff
$index = 0;
$nbdiff = count($diff);
diff --git a/htdocs/core/filemanagerdol/browser/default/browser.php b/htdocs/core/filemanagerdol/browser/default/browser.php
index b5bce100d39..0c1b29d12b2 100644
--- a/htdocs/core/filemanagerdol/browser/default/browser.php
+++ b/htdocs/core/filemanagerdol/browser/default/browser.php
@@ -21,10 +21,12 @@
//define('NOTOKENRENEWAL',1); // Disables token renewal
//require '../../../../main.inc.php';
-require '../../connectors/php/config.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
+require '../../connectors/php/config.inc.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
global $Config;
+top_httphead();
+
?>
diff --git a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php
index c66187ee433..949307c0624 100644
--- a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php
+++ b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php
@@ -23,6 +23,8 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal
require '../../../../main.inc.php';
+top_httphead();
+
?>
\n";
print '';
print ' ';
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
- print ' ';
+ print ' ';
$htmltext = $langs->trans("ProjectFollowTasks");
print ''.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).' ';
print ' ';
}
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
- print ' ';
+ print ' ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print ''.$form->textwithpicto($langs->trans("BillTime"), $htmltext).' ';
print ' ';
}
if (!empty($conf->eventorganization->enabled)) {
- print ' ';
+ print ' ';
$htmltext = $langs->trans("EventOrganizationDescriptionLong");
print ''.$form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext).' ';
}
@@ -735,7 +739,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
print '';
- // Change probability from status
+ // Change probability from status or role of project
print '';
print ' ';
diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php
index 661ae6accfe..8bb85022b2e 100644
--- a/htdocs/public/eventorganization/attendee_new.php
+++ b/htdocs/public/eventorganization/attendee_new.php
@@ -60,6 +60,7 @@ global $dolibarr_main_url_root;
// Init vars
$errmsg = '';
+$errors = array();
$error = 0;
$backtopage = GETPOST('backtopage', 'alpha');
$action = GETPOST('action', 'aZ09');
@@ -90,6 +91,7 @@ if ($type == 'conf') {
if ($resultproject < 0) {
$error++;
$errmsg .= $project->error;
+ $errors = array_merge($errors, $project->errors);
}
}
@@ -99,6 +101,7 @@ if ($type == 'global') {
if ($resultproject < 0) {
$error++;
$errmsg .= $project->error;
+ $errors = array_merge($errors, $project->errors);
} else {
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."projet";
$sql .= " WHERE ".MAIN_DB_PREFIX."eventorganization_conferenceorboothattendee = ".((int) $project->id);
@@ -279,6 +282,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
if ($resultconfattendee < 0) {
$error++;
$errmsg .= $confattendee->error;
+ $errors = array_merge($errors, $confattendee->errors);
}
}
@@ -403,6 +407,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
// If an error was found
$error++;
$errmsg .= $thirdparty->error;
+ $errors = array_merge($errors, $thirdparty->errors);
} elseif ($resultfetchthirdparty == 0) { // No thirdparty found + a payment is expected
// Creation of a new thirdparty
if (!empty($societe)) {
@@ -441,6 +446,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
if ($readythirdparty < 0) {
$error++;
$errmsg .= $thirdparty->error;
+ $errors = array_merge($errors, $thirdparty->errors);
} else {
$thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs);
$thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs);
@@ -472,6 +478,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
if ($resultprod < 0) {
$error++;
$errmsg .= $productforinvoicerow->error;
+ $errors = array_merge($errors, $productforinvoicerow->errors);
} else {
$facture = new Facture($db);
if (empty($confattendee->fk_invoice)) {
@@ -668,7 +675,7 @@ if ($maxattendees && $currentnbofattendees >= $maxattendees) {
print ' ';
-dol_htmloutput_errors($errmsg);
+dol_htmloutput_errors($errmsg, $errors);
if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status == Project::STATUS_VALIDATED)) {
if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index 992e7ab403d..fbeba92516f 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -369,6 +369,7 @@ if ($ispaymentok) {
}
if (empty($user->rights->facture)) {
$user->rights->facture = new stdClass();
+ $user->rights->facture->invoice_advance = new stdClass();
}
if (empty($user->rights->adherent)) {
$user->rights->adherent = new stdClass();
@@ -376,6 +377,7 @@ if ($ispaymentok) {
}
$user->rights->societe->creer = 1;
$user->rights->facture->creer = 1;
+ $user->rights->facture->invoice_advance->validate = 1;
$user->rights->adherent->cotisation->creer = 1;
if (array_key_exists('MEM', $tmptag) && $tmptag['MEM'] > 0) {
diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php
index cb1b1089b0c..52193e4fcd4 100644
--- a/htdocs/public/project/suggestbooth.php
+++ b/htdocs/public/project/suggestbooth.php
@@ -101,7 +101,7 @@ $extrafields = new ExtraFields($db);
$user->loadDefaultValues();
$cactioncomm = new CActionComm($db);
-$arrayofeventtype = $cactioncomm->liste_array('', 'id', '', 0, "module='booth@eventorganization'");
+$arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='booth@eventorganization'");
// Security check
if (empty($conf->eventorganization->enabled)) {
@@ -612,8 +612,8 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
print '';
}
// Type of event
-print ''.$langs->trans("EventType").'* '."\n";
-print ''.FORM::selectarray('eventtype', $arrayofeventtype, $eventtype).' ';
+print ''.$langs->trans("Format").'* '."\n";
+print ''.Form::selectarray('eventtype', $arrayofconfboothtype, $eventtype, 1).' ';
// Label
print ''.$langs->trans("LabelOfBooth").'* '."\n";
print ' '."\n";
diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php
index 22589c941d2..05cc8e61a82 100644
--- a/htdocs/public/project/suggestconference.php
+++ b/htdocs/public/project/suggestconference.php
@@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db);
$user->loadDefaultValues();
$cactioncomm = new CActionComm($db);
-$arrayofeventtype = $cactioncomm->liste_array('', 'id', '', 0, "module='conference@eventorganization'");
+$arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='conference@eventorganization'");
// Security check
if (empty($conf->eventorganization->enabled)) {
@@ -463,8 +463,7 @@ print '';
print '
';
print '
';
-
-dol_htmloutput_errors($errmsg);
+dol_htmloutput_errors($errmsg, $errors);
// Print form
print '
';
@@ -652,6 +669,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$defaulttopic = 'InformationMessage';
$diroutput = $conf->recruitment->dir_output;
$trackid = 'recruitmentcandidature'.$object->id;
+ $inreplyto = $object->email_msgid;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php
index 25cdb80aa3e..cd3da93b9e0 100644
--- a/htdocs/recruitment/recruitmentcandidature_document.php
+++ b/htdocs/recruitment/recruitmentcandidature_document.php
@@ -48,7 +48,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
-$offset = $liste_limit * $page;
+$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php
index ed1b1b54711..996868a791e 100644
--- a/htdocs/recruitment/recruitmentjobposition_card.php
+++ b/htdocs/recruitment/recruitmentjobposition_card.php
@@ -21,41 +21,21 @@
* \brief Page to create/edit/view recruitmentjobposition
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters
-//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler
-//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
-//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies
-
-
// Load Dolibarr environment
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
-dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
+require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("recruitment", "other"));
// Get parameters
$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
+$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php
index 3845a53a4e3..d05ed9ab5d6 100644
--- a/htdocs/recruitment/recruitmentjobposition_document.php
+++ b/htdocs/recruitment/recruitmentjobposition_document.php
@@ -28,8 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
-dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
+require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
+require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("recruitment", "companies", "other", "mails"));
@@ -48,7 +48,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
-$offset = $liste_limit * $page;
+$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php
index ef9a882bd8e..54f244efc5b 100644
--- a/htdocs/recruitment/recruitmentjobposition_list.php
+++ b/htdocs/recruitment/recruitmentjobposition_list.php
@@ -216,7 +216,7 @@ $now = dol_now();
//$help_url="EN:Module_RecruitmentJobPosition|FR:Module_RecruitmentJobPosition_FR|ES:Módulo_RecruitmentJobPosition";
$help_url = '';
-$title = $langs->trans('ListOfPositionsToBeFilled');
+$title = $langs->trans('PositionsToBeFilled');
$morejs = array();
$morecss = array();
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index 717398c92d4..4ddbd1c613f 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -127,7 +127,7 @@ class CompanyBankAccount extends Account
// End call triggers
if (!$error) {
- return 1;
+ return $this->id;
} else {
return 0;
}
@@ -136,7 +136,7 @@ class CompanyBankAccount extends Account
}
}
} else {
- print $this->db->error();
+ $this->error = $this->db->lasterror();
return 0;
}
}
@@ -150,7 +150,7 @@ class CompanyBankAccount extends Account
*/
public function update(User $user = null, $notrigger = 0)
{
- global $conf;
+ global $conf, $langs;
$error = 0;
@@ -207,7 +207,11 @@ class CompanyBankAccount extends Account
return 1;
}
} else {
- $this->error = $this->db->lasterror();
+ if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+ $this->error = $langs->trans('ErrorDuplicateField');
+ } else {
+ $this->error = $this->db->lasterror();
+ }
return -1;
}
}
diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php
index 0f41ce6a56b..9e4c0e91137 100644
--- a/htdocs/societe/paymentmodes.php
+++ b/htdocs/societe/paymentmodes.php
@@ -1722,10 +1722,10 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) {
print '
';
print ''.$langs->trans("LabelRIB").' ';
- print ' ';
+ print ' ';
print ''.$langs->trans("Bank").' ';
- print ' ';
+ print ' ';
// Show fields of bank account
foreach ($companybankaccount->getFieldsToShow(1) as $val) {
@@ -1818,7 +1818,7 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) {
print dol_get_fiche_end();
- dol_set_focus('#label');
+ dol_set_focus('#bank');
print $form->buttonsSaveCancel("Add");
}
diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php
index 2cd61bfe5d0..7f17d51800d 100644
--- a/htdocs/stripe/charge.php
+++ b/htdocs/stripe/charge.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2018-2022 Thibault FOUCART
* Copyright (C) 2019 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
@@ -251,16 +251,15 @@ if (!$rowid) {
$object = new Commande($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
- print "".img_picto('', 'object_order')." ".$object->ref." ";
+ print "".img_picto('', 'order')." ".$object->ref." ";
} else {
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") {
- print $charge->metadata->dol_type.' '.$charge->metadata->dol_id.' - ';
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
- print "".img_picto('', 'object_invoice')." ".$object->ref." ";
+ print "".img_picto('', 'bill')." ".$object->ref." ";
} else {
print $FULLTAG;
}
diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php
index 00d3c4a0d94..5ec149ba07f 100644
--- a/htdocs/stripe/class/stripe.class.php
+++ b/htdocs/stripe/class/stripe.class.php
@@ -643,9 +643,6 @@ class Stripe extends CommonObject
if (!empty($conf->global->STRIPE_BANCONTACT)) {
$paymentmethodtypes[] = "bancontact";
}
- if (!empty($conf->global->STRIPE_KLARNA)) {
- $paymentmethodtypes[] = "klarna";
- }
if (!empty($conf->global->STRIPE_IDEAL)) {
$paymentmethodtypes[] = "ideal";
}
diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php
index 64ce74b6022..0bfe4ebd080 100644
--- a/htdocs/takepos/admin/terminal.php
+++ b/htdocs/takepos/admin/terminal.php
@@ -70,6 +70,8 @@ $terminaltouse = $terminal;
if (GETPOST('action', 'alpha') == 'set') {
$db->begin();
+ $res = dolibarr_set_const($db, "TAKEPOS_TERMINAL_NAME_".$terminaltouse, (!empty(GETPOST('terminalname'.$terminaltouse, 'restricthtml')) ? GETPOST('terminalname'.$terminaltouse, 'restricthtml') : $langs->trans("TerminalName", $terminaltouse)), 'chaine', 0, '', $conf->entity);
+
$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
@@ -148,6 +150,11 @@ print '';
print ''.$langs->trans("Parameters").' '.$langs->trans("Value").' ';
print " \n";
+print ''.$langs->trans("TerminalNameDesc").' ';
+print '';
+print ' trans("TerminalName", $terminal)).'" >';
+print ' ';
+
print ''.$langs->trans("CashDeskThirdPartyForSell").' ';
print '';
print $form->select_company($conf->global->{'CASHDESK_ID_THIRDPARTY'.$terminaltouse}, 'socid', '(s.client IN (1, 3) AND s.status = 1)', 1, 0, 0, array(), 0);
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index ee6a6c85d80..e9717e7c992 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -955,14 +955,9 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
- trans("Terminal"); ?>
+ trans("TerminalName", $_SESSION["takeposterminal"])); ?>
- - '.dol_print_date(dol_now(), "day").'';
?>
@@ -1019,11 +1014,11 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
trans("TerminalSelect"); ?>
- trans("Terminal"); ?> 1
+ trans("TerminalName", 1)); ?>
'.$langs->trans("Terminal").' '.$i.'';
+ print ''.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$i, $langs->trans("TerminalName", $i)).' ';
}
?>
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index e3f4a106c67..3657ca7f4b6 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -562,13 +562,20 @@ if (empty($reshook)) {
$invoice->fetch_thirdparty();
$array_options = array();
+ $line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'locatax1_tx' => $localtax1_tx, 'locatax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
+
// complete line by hook
- $parameters = array('prod' => $prod);
- $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action);
+ $parameters = array('prod' => $prod, 'line' => $line);
+ $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
if (empty($reshook)) {
- $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $array_options, 100, '', null, 0);
+ if (!empty($hookmanager->resArray)) {
+ $line = $hookmanager->resArray;
+ }
+
+ $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $line['array_options'], 100, '', null, 0);
}
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php
index f487862e895..24ca8cc782b 100644
--- a/htdocs/takepos/pay.php
+++ b/htdocs/takepos/pay.php
@@ -655,6 +655,10 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
}
}
+$parameters = array();
+$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $object may have been modified by hook
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
$class = ($i == 3) ? "calcbutton3" : "calcbutton2";
foreach ($action_buttons as $button) {
$newclass = $class.($button["class"] ? " ".$button["class"] : "");
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index 3886651e8d5..078d485a5c9 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -543,6 +543,7 @@ fieldset {
border: 1px solid #AAAAAA !important;
padding-inline-start: 2em;
padding-inline-end: 2em;
+ min-inline-size: auto;
}
.legendforfieldsetstep { padding-bottom: 10px; }
input#onlinepaymenturl, input#directdownloadlink {
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 6e423228df1..ca485fb0d5f 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -725,6 +725,7 @@ fieldset {
border: 1px solid #AAAAAA !important;
padding-inline-start: 2em;
padding-inline-end: 2em;
+ min-inline-size: auto;
}
.legendforfieldsetstep { padding-bottom: 10px; }
input#onlinepaymenturl, input#directdownloadlink {
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index e7fc3abba34..20c5d45dd3b 100755
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -56,6 +56,7 @@ $projectid = GETPOST('projectid', 'int');
$cancel = GETPOST('cancel', 'alpha');
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('$backtopage', 'alpha');
+$contactid = GETPOST('contactid', 'int');
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
@@ -171,7 +172,19 @@ if (empty($reshook)) {
if (GETPOST('save', 'alpha') && !empty($user->rights->ticket->write)) {
$error = 0;
- if (!GETPOST("subject", 'alphanohtml')) {
+ if (!GETPOST("type_code", 'alpha')) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTypeRequest")), null, 'errors');
+ $action = 'create';
+ } elseif (!GETPOST("category_code", 'alpha')) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketCategory")), null, 'errors');
+ $action = 'create';
+ } elseif (!GETPOST("severity_code", 'alpha')) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketSeverity")), null, 'errors');
+ $action = 'create';
+ } elseif (!GETPOST("subject", 'alphanohtml')) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
$action = 'create';
@@ -924,15 +937,17 @@ if ($action == 'create' || $action == 'presend') {
if ($object->fk_user_create > 0) {
$morehtmlref .= ' '.$langs->trans("CreatedBy").' : ';
- $langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$morehtmlref .= $fuser->getNomUrl(-1);
- }
- if (!empty($object->origin_email)) {
+ } elseif (!empty($object->email_msgid)) {
$morehtmlref .= ' '.$langs->trans("CreatedBy").' : ';
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
- $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("TicketEmailOriginIssuer").') ';
+ $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).') ';
+ } elseif (!empty($object->origin_email)) {
+ $morehtmlref .= ' '.$langs->trans("CreatedBy").' : ';
+ $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
+ $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").') ';
}
// Thirdparty
@@ -1018,6 +1033,23 @@ if ($action == 'create' || $action == 'presend') {
print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).' ';
print ' ';
+ // Origin
+ /*
+ if ($object->email_msgid) {
+ $texttoshow = $langs->trans("CreatedByEmailCollector");
+ } elseif ($object->origin_email) {
+ $texttoshow = $langs->trans("FromPublicEmail");
+ }
+ if ($texttoshow) {
+ print '';
+ print $langs->trans("Origin");
+ print ' ';
+ print '';
+ print $texttoshow;
+ print ' ';
+ }
+ */
+
// Read date
print ''.$langs->trans("TicketReadOn").' ';
if (!empty($object->date_read)) {
@@ -1038,7 +1070,7 @@ if ($action == 'create' || $action == 'presend') {
print ' ';
print '';
print $langs->trans("AssignedTo");
- if ($object->fk_status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
+ if (isset($object->fk_status) && $object->fk_status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
print ' '.img_edit($langs->trans('Modify'), '').' ';
}
print '
';
@@ -1066,7 +1098,7 @@ if ($action == 'create' || $action == 'presend') {
print '';
print $langs->trans('Progression').' ';
print ' ';
- if ($action != 'progression' && $object->fk_status < $object::STATUS_CLOSED && !$user->socid) {
+ if ($action != 'progression' && isset($object->fk_status) && $object->fk_status < $object::STATUS_CLOSED && !$user->socid) {
print ''.img_edit($langs->trans('Modify')).' ';
}
print '
';
@@ -1117,6 +1149,7 @@ if ($action == 'create' || $action == 'presend') {
// Fin colonne gauche et début colonne droite
print '