Feature Request: Dolibarr API - [GET] /bankaccounts/{id}/lines : add sqlfilters #11259
This commit is contained in:
parent
a300cb9067
commit
9c160d5181
@ -411,8 +411,9 @@ class BankAccounts extends DolibarrApi
|
|||||||
* @throws RestException
|
* @throws RestException
|
||||||
*
|
*
|
||||||
* @url GET {id}/lines
|
* @url GET {id}/lines
|
||||||
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
|
||||||
*/
|
*/
|
||||||
public function getLines($id)
|
public function getLines($id, $sqlfilters = '')
|
||||||
{
|
{
|
||||||
$list = array();
|
$list = array();
|
||||||
|
|
||||||
@ -428,6 +429,18 @@ class BankAccounts extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank ";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank ";
|
||||||
$sql .= " WHERE fk_account = ".$id;
|
$sql .= " WHERE fk_account = ".$id;
|
||||||
|
|
||||||
|
// Add sql filters
|
||||||
|
if ($sqlfilters)
|
||||||
|
{
|
||||||
|
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||||
|
{
|
||||||
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
|
}
|
||||||
|
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
|
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||||
|
}
|
||||||
|
|
||||||
$sql .= " ORDER BY rowid";
|
$sql .= " ORDER BY rowid";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user