2
0
forked from Wavyzz/dolibarr

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/commande/class/api_orders.class.php
	htdocs/compta/facture/card.php
	htdocs/core/lib/functions.lib.php
	htdocs/core/lib/project.lib.php
	htdocs/fourn/class/api_supplier_orders.class.php
	htdocs/fourn/class/fournisseur.facture-rec.class.php
	htdocs/langs/en_US/stocks.lang
This commit is contained in:
Laurent Destailleur
2023-11-17 18:24:53 +01:00
35 changed files with 164 additions and 74 deletions

View File

@@ -156,16 +156,15 @@ class Orders extends DolibarrApi
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $sqlfilterlines Other criteria to filter answers separated by a comma. Syntax example "(tl.fk_product:=:'17') and (tl.price:<:'250')"
* @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names
* @return array Array of order objects
*
* @throws RestException 404 Not found
* @throws RestException 503 Error
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '')
{
global $db, $conf;
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(401);
}
@@ -213,7 +212,16 @@ class Orders extends DolibarrApi
throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
}
// Add sql filters for lines
if ($sqlfilterlines) {
$errormessage = '';
$sql .= " AND EXISTS (SELECT tl.rowid FROM ".MAIN_DB_PREFIX."commandedet AS tl WHERE tl.fk_commande = t.rowid";
$sql .= forgeSQLFromUniversalSearchCriteria($sqlfilterlines, $errormessage);
$sql .= ")";
if ($errormessage) {
throw new RestException(400, 'Error when validating parameter sqlfilterlines -> '.$errormessage);
}
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {