diff --git a/.gitignore b/.gitignore index 434764e4f06..a582d0807a3 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ dev/build/node_modules/ node_modules/ vendor/ +php-vendor tmp/ #yarn diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 1afde9322b3..e3ac6a47b5b 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -68,11 +68,11 @@ class AdherentStats extends Stats /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler - * @param int $socid Id third party - * @param int $userid Id user for filter + * @param DoliDB $db Database handler + * @param int $socid Id third party + * @param int $userid Id user for filter */ public function __construct($db, $socid = 0, $userid = 0) { @@ -97,11 +97,11 @@ class AdherentStats extends Stats /** - * Return the number of proposition by month for a given year + * Return the number of members by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array,array{0:int<1,12>,1:int}> Array of nb each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array,array{0:int<1,12>,1:int}> Array of nb each month */ public function getNbByMonth($year, $format = 0) { @@ -136,7 +136,7 @@ class AdherentStats extends Stats * * @param int $year Year * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array,array{0:int<1,12>,1:int|float}> Array of values by month + * @return array,array{0:int<1,12>,1:int|float}> Array of values by month */ public function getAmountByMonth($year, $format = 0) { @@ -375,7 +375,7 @@ class AdherentStats extends Stats 'datem' => $this->db->jdate($objp->datem), 'status' => (int) $objp->status, 'date_end_subscription' => $this->db->jdate($objp->date_end_subscription), - 'photo' => $objp->photo, + 'photo' => isset($objp->photo) ? (string) $objp->photo : null, 'email' => $objp->email, 'gender' => $objp->gender, 'morphy' => $objp->morphy, diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 40a3b69a472..4f7224cc5ee 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -26,6 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherentstats.class.php'; /** @@ -44,6 +45,11 @@ class Members extends DolibarrApi 'typeid' ); + /** + * @var AdherentStats + */ + public $memberstats; + /** * Constructor */ @@ -51,6 +57,7 @@ class Members extends DolibarrApi { global $db; $this->db = $db; + $this->memberstats = new AdherentStats($this->db, DolibarrApiAccess::$user->socid, DolibarrApiAccess::$user->id); } /** @@ -982,6 +989,91 @@ class Members extends DolibarrApi ); } + /** + * Return an array with the number of members by month for a given year + * + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text + * 1=Label of abscissa is month number + * 2=Label of abscissa is first letter of month + * @return array Array of statistics for last modified members + * @phan-return array,array{0:int<1,12>,1:int}> Array of nb each month + * @phpstan-return array,array{0:int<1,12>,1:int}> Array of nb each month + * + * @url GET stats/nbbymonth + * @throws RestException 403 Access denied + */ + public function getNbByMonth($year, $format = 0) + { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { + throw new RestException(403); + } + + return $this->memberstats->getNbByMonth($year, $format); + } + + /** + * Return an array with the number of subscriptions by year + * + * @return array Array of statistics for last modified members + * @phan-return array Array of nb each year + * @phpstan-return array Array of nb each year + * + * @url GET stats/nbbyyear + * @throws RestException 403 Access denied + */ + public function getNbByYear() + { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { + throw new RestException(403); + } + + return $this->memberstats->getNbByYear(); + } + + /** + * Return the number of subscriptions by month for a given year + * + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of statistics for last modified members + * @phan-return array,array{0:int<1,12>,1:int|float}> Array of values by month + * @phpstan-return array,array{0:int<1,12>,1:int|float}> Array of values by month + * + * @url GET stats/amountbymonth + * @throws RestException 403 Access denied + */ + public function getAmountByMonth($year, $format = 0) + { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { + throw new RestException(403); + } + + return $this->memberstats->getAmountByMonth($year, $format); + } + + /** + * Last Modified Members + * + * Get an array of statistics for last modified members + * + * @param int $max Max numbers of members + * @return array Array of statistics for last modified members + * @phan-return array + * @phpstan-return array + * + * @url GET stats/lastmodifiedmembers + * @throws RestException 403 Access denied + */ + public function getLastModifiedMembers($max) + { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { + throw new RestException(403); + } + + return $this->memberstats->getLastModifiedMembers($max); + } + /** * Validate fields before creating an object * diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index cfbf8d0f98c..0d4b1c08751 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -252,7 +252,7 @@ if (empty($error) && !empty($xml)) { $out .= ''."\n"; $out .= ''.$langs->trans("ModuleMustBeEnabled", $langs->transnoentitiesnoconv("BlockedLog")).''."\n"; $out .= ''.yn(1).''."\n"; - $out .= ''.yn(isModEnabled('blockedlog')).''."\n"; + $out .= ''.yn(isModEnabled('blockedlog') ? 1 : 0).''."\n"; $out .= "\n"; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 5e5ff698d6c..8aa1965e5ad 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2653,7 +2653,7 @@ function getModuleDirForApiClass($moduleobject) $moduledirforclass = 'contrat'; } elseif (in_array($moduleobject, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents', 'objectlinks'))) { $moduledirforclass = 'api'; - } elseif ($moduleobject == 'contact' || $moduleobject == 'contacts' || $moduleobject == 'customer' || $moduleobject == 'thirdparty' || $moduleobject == 'thirdparties') { + } elseif (in_array($moduleobject, ['contact', 'contacts', 'customer', 'thirdparty', 'thirdparties'])) { $moduledirforclass = 'societe'; } elseif ($moduleobject == 'propale' || $moduleobject == 'proposals') { $moduledirforclass = 'comm/propal'; @@ -2661,7 +2661,7 @@ function getModuleDirForApiClass($moduleobject) $moduledirforclass = 'comm/action'; } elseif ($moduleobject == 'mailing') { $moduledirforclass = 'comm/mailing'; - } elseif ($moduleobject == 'adherent' || $moduleobject == 'members' || $moduleobject == 'memberstypes' || $moduleobject == 'subscriptions') { + } elseif (in_array($moduleobject, ['adherent', 'members', 'memberstypes', 'subscriptions'])) { $moduledirforclass = 'adherents'; } elseif ($moduleobject == 'don' || $moduleobject == 'donations') { $moduledirforclass = 'don'; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index aa0d59ce6df..c5f27da8e80 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -156,7 +156,7 @@ class modMyModule extends DolibarrModules $this->langfiles = array("mymodule@mymodule"); // Prerequisites - $this->phpmin = array(7, 1); // Minimum version of PHP required by module + $this->phpmin = array(7, 2); // Minimum version of PHP required by module // $this->phpmax = array(8, 0); // Maximum version of PHP required by module $this->need_dolibarr_version = array(19, -3); // Minimum version of Dolibarr required by module // $this->max_dolibarr_version = array(19, -3); // Maximum version of Dolibarr required by module diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2352365218b..9ae3c7e28da 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2435,7 +2435,8 @@ class Product extends CommonObject $price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; $price_min_ttc = $this->multiprices_min_ttc[$thirdparty_buyer->price_level]; $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level]; - if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) { // using this option is a bug. kept for backward compatibility + if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) { + // using this option is a bug. kept for backward compatibility if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) { $tva_tx = $this->multiprices_tva_tx[$thirdparty_buyer->price_level]; } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 6edb5adef26..faf1efec99b 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 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 @@ -1354,7 +1354,7 @@ if (isset($_SESSION["takeposterminal"]) && $_SESSION["takeposterminal"]) { $sql .= " AND active = 1"; $sql .= " ORDER BY libelle"; - $resql = $db->query($sql); + $resql = $db->query($sql); $paiementsModes = array(); if ($resql) { while ($obj = $db->fetch_object($resql)) {