diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index f9c53daef42..9fd9846589a 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -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 diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c2d23969900..59583de059f 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -4,11 +4,10 @@ * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent - * Copyright (C) 2018-2024 Alexandre Spangaro + * Copyright (C) 2018-2026 Alexandre Spangaro * Copyright (C) 2021-2025 Frédéric France * Copyright (C) 2024-2026 MDW * Copyright (C) 2024 Benjamin Falière - * Copyright (C) 2024 Alexandre Spangaro * * 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 ''; } +// No email (unsubscribe) +if (!empty($arrayfields['unsubscribed']['checked'])) { + print ''; + print $form->selectarray('search_no_email', array('-1' => '', '0' => $langs->trans('No'), '1' => $langs->trans('Yes')), $search_no_email); + print ''; +} + // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; @@ -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 ''.yn(($obj->unsubscribed > 0) ? 1 : 0)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } // End of subscription date $datefin = $db->jdate($obj->datefin); if (!empty($arrayfields['d.datefin']['checked'])) { diff --git a/htdocs/blockedlog/admin/registration.php b/htdocs/blockedlog/admin/registration.php index e7572b104c6..8d325f422fb 100644 --- a/htdocs/blockedlog/admin/registration.php +++ b/htdocs/blockedlog/admin/registration.php @@ -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 diff --git a/htdocs/core/lib/profid.lib.php b/htdocs/core/lib/profid.lib.php index c2415c9d388..55e5aaded62 100644 --- a/htdocs/core/lib/profid.lib.php +++ b/htdocs/core/lib/profid.lib.php @@ -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 diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f4a051407d5..df40ccdfacf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -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|-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)."'"; }