mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge pull request #20053 from ptibogxiv/patch-5
NEW API REST filter states by country
This commit is contained in:
commit
a71bdc4024
|
|
@ -239,7 +239,6 @@ class Setup extends DolibarrApi
|
|||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of states/provinces.
|
||||
*
|
||||
|
|
@ -252,22 +251,29 @@ class Setup extends DolibarrApi
|
|||
* @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 int $country To filter on country
|
||||
* @param string $filter To filter the states by name
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return array List of countries
|
||||
* @return array List of states
|
||||
*
|
||||
* @url GET dictionary/states
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $sqlfilters = '')
|
||||
public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '')
|
||||
{
|
||||
$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_departements as t";
|
||||
$sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
|
||||
if ($country) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as d ON t.fk_region = d.code_region";
|
||||
}
|
||||
$sql .= " WHERE 1 = 1";
|
||||
if ($country) {
|
||||
$sql .= " AND d.fk_pays = ".((int) $country);
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
$errormessage = '';
|
||||
|
|
@ -1301,7 +1307,7 @@ class Setup extends DolibarrApi
|
|||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $country To filter on country
|
||||
* @param int $country To filter on country
|
||||
* @param int $active Lega form is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return array List of legal form
|
||||
|
|
@ -1310,7 +1316,7 @@ class Setup extends DolibarrApi
|
|||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = '', $active = 1, $sqlfilters = '')
|
||||
public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
|
|
@ -1318,7 +1324,7 @@ class Setup extends DolibarrApi
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as t";
|
||||
$sql .= " WHERE t.active = ".((int) $active);
|
||||
if ($country) {
|
||||
$sql .= " AND t.fk_pays = '".$this->db->escape($country)."'";
|
||||
$sql .= " AND t.fk_pays = ".((int) $country);
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user