diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 7c9e58cd42cce695ed1f5eab74ae693fcb84ef3f..d18bbdbc106b495cc4a964c4c4d67895389c0ac2 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -79,18 +79,18 @@ class Members extends DolibarrApi * * Get a list of members * - * @param string $typeid ID of the type of member - * @param string $login To filter the members by login - * @param string $name To filter the members by name (firstname, lastname or company name matching the filter) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param string $typeid ID of the type of member + * @param string $login To filter the members by login + * @param string $name To filter the members by name (firstname, lastname or company name matching the filter) * @return array Array of member objects * * @throws RestException */ - function index($typeid = '', $login = '', $name = '', $sortfield = "a.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "a.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $typeid = '', $login = '', $name = '') { global $db, $conf; $obj_ret = array(); @@ -136,7 +136,7 @@ class Members extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($limit, $num)) { $obj = $db->fetch_object($result); $member = new Adherent($this->db); diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 09e816395716d7e5f77676616eae659c142ee8de..4f8435c3a1d64fb7c419c5439171bb51ac49e8b8 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -119,7 +119,7 @@ class Subscriptions extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($limit, $num)) { $obj = $db->fetch_object($result); $subscription = new Subscription($this->db); diff --git a/htdocs/api/class/api_countries.class.php b/htdocs/api/class/api_dictionnarycountries.class.php similarity index 84% rename from htdocs/api/class/api_countries.class.php rename to htdocs/api/class/api_dictionnarycountries.class.php index 9dbe3fc215dd6b75e74ae74f07b32c7d67efdf46..77e8f63f2588dc9e4bdb64eddebd2a349db1a471 100644 --- a/htdocs/api/class/api_countries.class.php +++ b/htdocs/api/class/api_dictionnarycountries.class.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; * @access protected * @class DolibarrApiAccess {@requires user,external} */ -class Countries extends DolibarrApi +class DictionnaryCountries extends DolibarrApi { private $translations = null; @@ -48,22 +48,33 @@ class Countries extends DolibarrApi * code supported by Dolibarr, for example 'en_US' or 'fr_FR'. * The returned list is sorted by country ID. * - * @param string $filter To filter the countries by name - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $lang Code of the language the names of the - * countries must be translated to + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $filter To filter the countries by name + * @param string $lang Code of the language the label of the countries must be translated to * @return List of countries * * @throws RestException */ - function index($filter = '', $limit = 0, $page = 0, $lang = '') + function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '') { $list = array(); // Note: The filter is not applied in the SQL request because it must // be applied to the translated names, not to the names in database. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country ORDER BY rowid"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country"; + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $this->db->query($sql); + $nbtotalofrecords = $this->db->num_rows($result); + } + + $sql.= $this->db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { diff --git a/htdocs/api/class/api_towns.class.php b/htdocs/api/class/api_dictionnarytowns.class.php similarity index 64% rename from htdocs/api/class/api_towns.class.php rename to htdocs/api/class/api_dictionnarytowns.class.php index aa99e9e93bdd7f16ad7f1b598cc5631a4102978c..a08d4387edce908a6f65624638cbfa39be457b98 100644 --- a/htdocs/api/class/api_towns.class.php +++ b/htdocs/api/class/api_dictionnarytowns.class.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; * @access protected * @class DolibarrApiAccess {@requires user,external} */ -class Towns +class DictionnaryTowns extends DolibarrApi { /** * Constructor @@ -41,23 +41,44 @@ class Towns /** * Get the list of towns. * - * @param string $zipcode To filter the towns by zipcode - * @param string $town To filter the towns by name + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $zipcode To filter on zipcode + * @param string $town To filter on city name * @return List of towns * * @throws RestException */ - function index($zipcode = '', $town = '') + function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '') { $list = array(); $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown"; $sql.= " WHERE active = 1"; - if ($zipcode) $sql.=" AND zip LIKE '" . $this->db->escape($zipcode) . "%'"; + if ($zipcode) $sql.=" AND zip LIKE '%" . $this->db->escape($zipcode) . "%'"; if ($town) $sql.=" AND town LIKE '%" . $this->db->escape($town) . "%'"; - $sql.= " ORDER BY zip, town"; + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $this->db->query($sql); + $nbtotalofrecords = $this->db->num_rows($result); + } + + $sql.= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index cab361329444c40298b9b56934bd85a58b8d4d27..bea6061e0febb5c6cb1774e683b4ad04397bab02 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -93,16 +93,16 @@ class Categories extends DolibarrApi * * Get a list of categories * - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @return array Array of category objects * * @throws RestException */ - function index($type = '', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type = '') { global $db, $conf; $obj_ret = array(); @@ -142,7 +142,7 @@ class Categories extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); @@ -167,17 +167,17 @@ class Categories extends DolibarrApi * Note: This method is not directly exposed in the API, it is used * in the GET /xxx/{id}/categories requests. * - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param int $item Id of the item to get categories for * @return array Array of category objects * * @access private */ - function getListForItem($type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $item = 0) { + function getListForItem($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type='customer', $item = 0) { global $db, $conf; $obj_ret = array(); @@ -228,7 +228,7 @@ class Categories extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); diff --git a/htdocs/categories/class/api_deprecated_category.class.php b/htdocs/categories/class/api_deprecated_category.class.php index 656c769bed360363c7de8eb9688f1db2df601a67..e18ada34e0a9b3db24ce2c12c45ed0550047c16b 100644 --- a/htdocs/categories/class/api_deprecated_category.class.php +++ b/htdocs/categories/class/api_deprecated_category.class.php @@ -147,7 +147,7 @@ class CategoryApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); @@ -228,7 +228,7 @@ class CategoryApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 3022a5aaa1de30fb23385c2227aed54ad328dd8e..c245476bdccb0955714135f67ad713a2f15f693a 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -97,7 +97,7 @@ class AgendaEvents extends DolibarrApi * * @return array Array of Agenda Events objects */ - function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0) { + function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0) { global $db, $conf; $obj_ret = array(); @@ -139,7 +139,7 @@ class AgendaEvents extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $actioncomm_static = new ActionComm($db); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9a33c4d7cbc1018f6902558068f34ea96d22ddd1..9569815487040304f4a3c9ef16ad094f95be4133 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -143,7 +143,7 @@ class Proposals extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $propal_static = new Propal($db); diff --git a/htdocs/commande/class/api_deprecated_commande.class.php b/htdocs/commande/class/api_deprecated_commande.class.php index b36ea27f6ccd11baad9dc912825df3ab0278a31d..bc04ec5fe77bfa12b0bafbd7a8f9875a647b907b 100644 --- a/htdocs/commande/class/api_deprecated_commande.class.php +++ b/htdocs/commande/class/api_deprecated_commande.class.php @@ -97,17 +97,17 @@ class CommandeApi extends DolibarrApi * * Get a list of orders * - * @param int $mode Use this param to filter list * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $societe Societe filter field + * @param int $mode Use this param to filter list + * @param string $societe Thirdparty filter field * * @url GET /order/list * @return array Array of order objects */ - function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $societe = 0) { + function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $societe = 0) { global $db, $conf; $obj_ret = array(); @@ -162,7 +162,7 @@ class CommandeApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $commande_static = new Commande($db); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 86af4b2f5be353ca4ac3ae2024309a5d67ca86ae..07cf9f8febed925dba9ff1bbbc4511c9d65daf8c 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -92,7 +92,7 @@ class Orders extends DolibarrApi * * @return array Array of order objects */ - function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '') { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '') { global $db, $conf; $obj_ret = array(); @@ -142,7 +142,7 @@ class Orders extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($limit, $num)) { $obj = $db->fetch_object($result); $commande_static = new Commande($db); diff --git a/htdocs/compta/facture/class/api_deprecated_invoice.class.php b/htdocs/compta/facture/class/api_deprecated_invoice.class.php index 353a48b79efb8e9eeb238e8596634d4ace5645ab..51e047e44126d9c253996d0638bb70cb10e7be20 100644 --- a/htdocs/compta/facture/class/api_deprecated_invoice.class.php +++ b/htdocs/compta/facture/class/api_deprecated_invoice.class.php @@ -89,12 +89,12 @@ class InvoiceApi extends DolibarrApi * * Get a list of invoices * - * @param int $socid Filter list with thirdparty ID - * @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid Filter list with thirdparty ID + * @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled * * @return array Array of invoice objects * @@ -103,12 +103,12 @@ class InvoiceApi extends DolibarrApi * @url GET thirdparty/{socid}/invoice/list * @url GET thirdparty/{socid}/invoice/list/{mode} */ - function getList($socid=0, $mode='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $mode='') { global $db, $conf; $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -160,7 +160,7 @@ class InvoiceApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $invoice_static = new Facture($db); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e14ed12dce31a62a556d235cd0e974b69a1f63a4..e3951b4dca754d2243b78261610e9d4e68b96004 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -83,23 +83,22 @@ class Invoices extends DolibarrApi * * Get a list of invoices * - * FIXME this parameter is overwritten in the code and thus ignored - * @param int $socid Filter list with thirdparty ID - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid Filter list with thirdparty ID + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @return array Array of invoice objects * * @throws RestException */ - function index($socid=0, $status='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $status='') { global $db, $conf; $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -151,7 +150,7 @@ class Invoices extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $invoice_static = new Facture($db); diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 687b6ce983ee9ebedc00a807c79e47b78380e236..298a178f00c53082107a039e79dae64401acc74c 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -136,7 +136,7 @@ class ExpenseReports extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $expensereport_static = new ExpenseReport($db); diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php index 2db0699d66184a15e1bf60db087df0e2e1a31b44..d4ad8335f54258a919b259716ad4c16d2fe9b042 100644 --- a/htdocs/product/class/api_deprecated_product.class.php +++ b/htdocs/product/class/api_deprecated_product.class.php @@ -94,19 +94,19 @@ class ProductApi extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects * * @url GET /product/list */ - function getList($mode=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -149,7 +149,7 @@ class ProductApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); @@ -174,20 +174,20 @@ class ProductApi extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param int $category Use this param to filter list by category - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects * * @url GET /product/list/category/{category} */ - function getByCategory($mode=0, $category=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getByCategory($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $category=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -235,7 +235,7 @@ class ProductApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index d6dc8770b239c5c5beca8fac18f8d675e7a264b2..210ea09d3d3fd294200a7bda786f0e6802eee51a 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -87,18 +87,18 @@ class Products extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param int $category Use this param to filter list by category - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects */ - function index($mode=0, $category=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $category=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -151,7 +151,7 @@ class Products extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index cd0dd6ae38fce9af0a71c98b908f4e2c9e4f84d8..8431f294469ff59263f9489469136fc6d0751144 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -84,16 +84,16 @@ class Contacts extends DolibarrApi * * Get a list of contacts * - * @param int $socid ID of thirdparty to filter list * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid ID of thirdparty to filter list * @return array Array of contact objects * * @throws RestException */ - function index($socid = 0, $sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid = 0) { global $db, $conf; $obj_ret = array(); @@ -154,7 +154,7 @@ class Contacts extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $contact_static = new Contact($db); diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php index 2a6a4b948b896bd058f4e0c8112954e7a2c95341..e645c3e15ff9e61de13a7fb63fba4022da48af3b 100644 --- a/htdocs/societe/class/api_deprecated_contact.class.php +++ b/htdocs/societe/class/api_deprecated_contact.class.php @@ -167,7 +167,7 @@ class ContactApi extends DolibarrApi { $i = 0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $contact_static = new Contact($db); diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index 3e2f070b9de6f3de715d980d1571689de4422220..3179cb697ce96f86277620e4f2d004cdab715013 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -213,7 +213,7 @@ class ThirdpartyApi extends DolibarrApi { $i = 0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $soc_static = new Societe($db); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 12fca598a810833a7e12027b7dc70e5bcc26f30a..a520a7c8f83fe18a28952ca5430a559aecca67f9 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -87,17 +87,17 @@ class Thirdparties extends DolibarrApi * * Get a list of thirdparties * - * @param int $mode Set to 1 to show only customers - * Set to 2 to show only prospects - * Set to 3 to show only those are not customer neither prospect - * @param string $email Search by email filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Set to 1 to show only customers + * Set to 2 to show only prospects + * Set to 3 to show only those are not customer neither prospect + * @param string $email Search by email filter * @return array Array of thirdparty objects */ - function index($mode=0, $email=NULL, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $email=NULL) { global $db, $conf; $obj_ret = array(); @@ -152,7 +152,7 @@ class Thirdparties extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $soc_static = new Societe($db); diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index bf75758fe5c46c33c49612ff94e212cf46b5046d..c046c9869cf68ba78e5e6da958408945cdae4c78 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -103,7 +103,7 @@ class Users extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $user_static = new User($db);