forked from Wavyzz/dolibarr
NEW : Add pagination data to some api routes (#29895)
* Add pagination date * Spaces to tabs * fix
This commit is contained in:
@@ -158,9 +158,10 @@ class Proposals extends DolibarrApi
|
|||||||
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposals (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposals (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.datec:<:'2016-01-01')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'2016-01-01')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of order objects
|
* @return array Array of order objects
|
||||||
*/
|
*/
|
||||||
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 = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -201,6 +202,9 @@ class Proposals extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total proposals with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -235,6 +239,23 @@ class Proposals extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve propal list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve propal list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,12 +158,13 @@ class Orders extends DolibarrApi
|
|||||||
* @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 $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 $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 these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of order objects
|
* @return array Array of order objects
|
||||||
*
|
*
|
||||||
* @throws RestException 404 Not found
|
* @throws RestException 404 Not found
|
||||||
* @throws RestException 503 Error
|
* @throws RestException 503 Error
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -213,6 +214,10 @@ class Orders extends DolibarrApi
|
|||||||
throw new RestException(400, 'Error when validating parameter sqlfilterlines -> '.$errormessage);
|
throw new RestException(400, 'Error when validating parameter sqlfilterlines -> '.$errormessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total orders with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -251,6 +256,23 @@ class Orders extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,12 +179,13 @@ class Invoices extends DolibarrApi
|
|||||||
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
|
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
|
||||||
* @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 $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0
|
||||||
* @return array Array of invoice objects
|
* @return array Array of invoice objects
|
||||||
*
|
*
|
||||||
* @throws RestException 404 Not found
|
* @throws RestException 404 Not found
|
||||||
* @throws RestException 503 Error
|
* @throws RestException 503 Error
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -238,6 +239,9 @@ class Invoices extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total invoices with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -280,6 +284,23 @@ class Invoices extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve invoice list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve invoice list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,11 +95,12 @@ class Shipments extends DolibarrApi
|
|||||||
* @param string $thirdparty_ids Thirdparty ids to filter shipments of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
* @param string $thirdparty_ids Thirdparty ids to filter shipments 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 $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of shipment objects
|
* @return array Array of shipment objects
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
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 = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -140,6 +141,9 @@ class Shipments extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total shipments with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -169,6 +173,23 @@ class Shipments extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,11 +98,12 @@ class SupplierInvoices extends DolibarrApi
|
|||||||
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
|
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
|
||||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of invoice objects
|
* @return array Array of invoice objects
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) {
|
if (!DolibarrApiAccess::$user->hasRight("fournisseur", "facture", "lire")) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -156,6 +157,9 @@ class SupplierInvoices extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total supplier invoices with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -183,6 +187,23 @@ class SupplierInvoices extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve supplier invoice list : ' . $this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve supplier invoice list : ' . $this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,11 +95,12 @@ class SupplierOrders extends DolibarrApi
|
|||||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'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 $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 these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of order objects
|
* @return array Array of order objects
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $product_ids = '', $status = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "lire")) {
|
if (!DolibarrApiAccess::$user->hasRight("fournisseur", "commande", "lire")) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -181,6 +182,9 @@ class SupplierOrders extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total supplier orders with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -208,6 +212,23 @@ class SupplierOrders extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve supplier order list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve supplier order list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,11 +95,12 @@ class Receptions extends DolibarrApi
|
|||||||
* @param string $thirdparty_ids Thirdparty ids to filter receptions of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
* @param string $thirdparty_ids Thirdparty ids to filter receptions 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 $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of reception objects
|
* @return array Array of reception objects
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
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 = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -140,6 +141,9 @@ class Receptions extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total receptions with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -169,6 +173,23 @@ class Receptions extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,9 +131,10 @@ class Thirdparties extends DolibarrApi
|
|||||||
* @param int $category Use this param to filter list by category
|
* @param int $category Use this param to filter list by category
|
||||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "((t.nom:like:'TheCompany%') or (t.name_alias:like:'TheCompany%')) and (t.datec:<:'20160101')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "((t.nom:like:'TheCompany%') or (t.name_alias:like:'TheCompany%')) and (t.datec:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of thirdparty objects
|
* @return array Array of thirdparty objects
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $properties = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
@@ -203,8 +204,10 @@ class Thirdparties extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
//this query will return total thirdparties with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
@@ -236,6 +239,24 @@ class Thirdparties extends DolibarrApi
|
|||||||
if (!count($obj_ret)) {
|
if (!count($obj_ret)) {
|
||||||
throw new RestException(404, 'Thirdparties not found');
|
throw new RestException(404, 'Thirdparties not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,9 +217,10 @@ class SupplierProposals extends DolibarrApi
|
|||||||
* @param string $thirdparty_ids Thirdparty ids to filter supplier proposals (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
* @param string $thirdparty_ids Thirdparty ids to filter supplier proposals (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.datec:<:'20160101')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
||||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||||
|
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
|
||||||
* @return array Array of order objects
|
* @return array Array of order objects
|
||||||
*/
|
*/
|
||||||
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 = '', $properties = '', $pagination_data = false)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->hasRight('supplier_proposal', 'lire')) {
|
if (!DolibarrApiAccess::$user->hasRight('supplier_proposal', 'lire')) {
|
||||||
throw new RestException(403);
|
throw new RestException(403);
|
||||||
@@ -260,6 +261,9 @@ class SupplierProposals extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this query will return total supplier proposals with the filters given
|
||||||
|
$sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
|
||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0) {
|
if ($page < 0) {
|
||||||
@@ -288,6 +292,23 @@ class SupplierProposals extends DolibarrApi
|
|||||||
throw new RestException(503, 'Error when retrieving supplier proposal list : '.$this->db->lasterror());
|
throw new RestException(503, 'Error when retrieving supplier proposal list : '.$this->db->lasterror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
|
||||||
|
if ($pagination_data) {
|
||||||
|
$totalsResult = $this->db->query($sqlTotals);
|
||||||
|
$total = $this->db->fetch_object($totalsResult)->total;
|
||||||
|
|
||||||
|
$tmp = $obj_ret;
|
||||||
|
$obj_ret = [];
|
||||||
|
|
||||||
|
$obj_ret['data'] = $tmp;
|
||||||
|
$obj_ret['pagination'] = [
|
||||||
|
'total' => (int) $total,
|
||||||
|
'page' => $page, //count starts from 0
|
||||||
|
'page_count' => ceil((int) $total / $limit),
|
||||||
|
'limit' => $limit
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user