Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop
This commit is contained in:
Laurent Destailleur 2026-05-26 06:36:25 +02:00
commit 614ff412de
5 changed files with 57 additions and 17 deletions

View file

@ -582,12 +582,6 @@ parameters:
count: 1
path: ../../../htdocs/admin/modules.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 1
path: ../../../htdocs/admin/modules.php
-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse

View file

@ -4,11 +4,10 @@
* Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2024 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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
@ -82,6 +81,11 @@ $search_phone_perso = GETPOST("search_phone_perso", 'alpha');
$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
$search_type = GETPOST("search_type", 'alpha');
$search_email = GETPOST("search_email", 'alpha');
if (isModEnabled('mailing')) {
$search_no_email = GETPOSTISSET("search_no_email") ? GETPOSTINT("search_no_email") : -1;
} else {
$search_no_email = -1;
}
$search_categ = GETPOST("search_categ", 'intcomma');
$search_morphy = GETPOST("search_morphy", 'alpha');
$search_import_key = trim(GETPOST("search_import_key", 'alpha'));
@ -153,6 +157,7 @@ $fieldstosearchall = array(
'd.firstname' => 'Firstname',
'd.societe' => "Company",
'd.email' => 'EMail',
'unsubscribed' => array('label' => 'No_Email', 'checked' => '0', 'enabled' => (string) (int) isModEnabled('mailing'), 'position' => 111),
'd.address' => 'Address',
'd.zip' => 'Zip',
'd.town' => 'Town',
@ -266,6 +271,7 @@ if (empty($reshook)) {
$search_company = "";
$search_type = "";
$search_email = "";
$search_no_email = -1;
$search_address = "";
$search_zip = "";
$search_town = "";
@ -422,6 +428,10 @@ $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyna
$sql .= " t.libelle as type, t.subscription,";
$sql .= " state.code_departement as state_code, state.nom as state_name";
if (isModEnabled('mailing')) {
$sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) as unsubscribed";
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
@ -536,6 +546,12 @@ if ($search_company) {
if ($search_email) {
$sql .= natural_search("d.email", $search_email);
}
if ($search_no_email != -1 && $search_no_email > 0) {
$sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) > 0";
}
if ($search_no_email != -1 && $search_no_email == 0) {
$sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = d.email) = 0 AND d.email IS NOT NULL AND d.email <> ''";
}
if ($search_address) {
$sql .= natural_search("d.address", $search_address);
}
@ -685,6 +701,9 @@ if ($search_login) {
if ($search_email) {
$query += ['search_email' => $search_email];
}
if ($search_no_email != -1) {
$query += ['search_no_email' => $search_no_email];
}
if ($search_categ > 0 || $search_categ == -2) {
$query += ['search_categ' => $search_categ];
}
@ -1017,6 +1036,13 @@ if (!empty($arrayfields['d.email']['checked'])) {
print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
}
// No email (unsubscribe)
if (!empty($arrayfields['unsubscribed']['checked'])) {
print '<td class="liste_titre center">';
print $form->selectarray('search_no_email', array('-1' => '', '0' => $langs->trans('No'), '1' => $langs->trans('Yes')), $search_no_email);
print '</td>';
}
// End of subscription date
if (!empty($arrayfields['d.datefin']['checked'])) {
print '<td class="liste_titre center">';
@ -1182,6 +1208,10 @@ if (!empty($arrayfields['d.email']['checked'])) {
print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['unsubscribed']['checked'])) {
print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], 'unsubscribed', '', $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.datefin']['checked'])) {
print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin,t.subscription', '', $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
@ -1477,6 +1507,13 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
// Unsubscribe from mass mailing
if (!empty($arrayfields['unsubscribed']['checked'])) {
print '<td class="center">'.yn(($obj->unsubscribed > 0) ? 1 : 0)."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// End of subscription date
$datefin = $db->jdate($obj->datefin);
if (!empty($arrayfields['d.datefin']['checked'])) {

View file

@ -424,14 +424,15 @@ if (empty($mode)) {
//Company email
$item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_EMAIL');
$item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email);
$item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_EMAIL') ? GETPOST('BLOCKEDLOG_REGISTRATION_EMAIL') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email));
$item->setAsEmail();
$item->fieldParams['isMandatory'] = 1;
$item->cssClass = "minwidth300 maxwidth500 widthcentpercentminusx";
//Company IDPROF1
$item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF1');
$item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1);
$item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_IDPROF1') ? GETPOST('BLOCKEDLOG_REGISTRATION_IDPROF1') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1));
$item->helpText = $langs->trans("Example").': '.$langs->trans("732 829 320");
$item->fieldParams['isMandatory'] = 1;
//Company country code

View file

@ -264,13 +264,15 @@ function isValidProfIds($idprof, $thirdparty)
}
// Check SIREN
if ($idprof == 1 && $thirdparty->country_code == 'FR' && !isValidSiren($thirdparty->idprof1)) {
return -1;
}
if ($thirdparty->country_code == 'FR') {
if ($idprof == 1 && !isValidSiren($thirdparty->idprof1)) {
return -1;
}
// Check SIRET
if ($idprof == 2 && $thirdparty->country_code == 'FR' && !isValidSiret($thirdparty->idprof2)) {
return -1;
// Check SIRET
if ($idprof == 2 && !isValidSiret($thirdparty->idprof2)) {
return -2;
}
}
// Verify CIF/NIF/NIE if pays ES

View file

@ -5711,9 +5711,10 @@ class Societe extends CommonObject
* @param int $list 0:Return array contains all properties, 1:Return array contains just id
* @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...)
* @param string $element Filter on this element of default contact type ('facture', 'propal', 'commande' ...)
* @param int $status Filter by contact status: 1=Active only, 0=Inactive only, -1=All (default)
* @return int[]|array<array{source:string,socid:int,id:int,nom:string,civility:string,lastname:string,firstname:string,email:string,login:string,photo:string,statuscontact:string,rowid:int,code:string,element:string,libelle:string,status:string,fk_c_type_contact:int}>|-1 Array of contacts, -1 if error
*/
public function getContacts($list = 0, $code = '', $element = '')
public function getContacts($list = 0, $code = '', $element = '', $status = -1)
{
// phpcs:enable
global $langs;
@ -5729,6 +5730,11 @@ class Societe extends CommonObject
$sql .= " LEFT JOIN ".$this->db->prefix()."socpeople t on sc.fk_socpeople = t.rowid";
$sql .= " WHERE sc.fk_soc = ".((int) $this->id);
$sql .= " AND sc.fk_c_type_contact = tc.rowid";
// Add status filter if requested
if ($status >= 0) {
$sql .= " AND t.statut = " . ((int) $status);
}
if (!empty($element)) {
$sql .= " AND tc.element = '".$this->db->escape($element)."'";
}