mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
NEW add api for members statistics (#35851)
* NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * NEW add api for members statistics * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -52,6 +52,7 @@ dev/build/node_modules/
|
||||
node_modules/
|
||||
|
||||
vendor/
|
||||
php-vendor
|
||||
tmp/
|
||||
|
||||
#yarn
|
||||
|
||||
@@ -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<int<0,11>,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<int<0,11>,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<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values by month
|
||||
* @return array<int<0,11>,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,
|
||||
|
||||
@@ -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<int<0,11>,array{0:int<1,12>,1:int}> Array of nb each month
|
||||
* @phpstan-return array<int<0,11>,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{0:int,1:int}> Array of nb each year
|
||||
* @phpstan-return array<array{0:int,1:int}> 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<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values by month
|
||||
* @phpstan-return array<int<0,11>,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<int,array{id:int,ref:string,firstname:string,lastname:string,company:string,fk_soc:?int,datec:int|'',datem:int|'',status:int,date_end_subscription:int|'',photo:null|string,email:string,gender:string,morphy:string,typeid:int,need_subscription:0|1|null,subscription:'0'|'1'|null,label:string}>
|
||||
* @phpstan-return array<int,array{id:int,ref:string,firstname:string,lastname:string,company:string,fk_soc:?int,datec:int|'',datem:int|'',status:int,date_end_subscription:int|'',photo:null|string,email:string,gender:string,morphy:string,typeid:int,need_subscription:0|1|null,subscription:'0'|'1'|null,label:string}>
|
||||
*
|
||||
* @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
|
||||
*
|
||||
|
||||
@@ -252,7 +252,7 @@ if (empty($error) && !empty($xml)) {
|
||||
$out .= '<td></td>'."\n";
|
||||
$out .= '<td>'.$langs->trans("ModuleMustBeEnabled", $langs->transnoentitiesnoconv("BlockedLog")).'</td>'."\n";
|
||||
$out .= '<td class="center">'.yn(1).'</td>'."\n";
|
||||
$out .= '<td class="center">'.yn(isModEnabled('blockedlog')).'</td>'."\n";
|
||||
$out .= '<td class="center">'.yn(isModEnabled('blockedlog') ? 1 : 0).'</td>'."\n";
|
||||
$out .= "</tr>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user