From 15e02c70824852f5ba2b5b3357b8d2d8974fe3e5 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Tue, 22 May 2018 11:40:32 +0200 Subject: [PATCH 1/2] NEW : adds billing contacts ids to REST API returns adds billing contacts ids to REST API returns for proposals, orders and invoices --- htdocs/comm/propal/class/api_proposals.class.php | 7 ++++++- htdocs/commande/class/api_orders.class.php | 4 ++++ htdocs/compta/facture/class/api_invoices.class.php | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index d153489dcc8..6d5a20b60bc 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -77,6 +77,9 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Add billing contacts ids + $this->propal->billing_contacts_ids = $this->propal->liste_contact(-1,'external',1,'BILLING'); + $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); } @@ -156,6 +159,8 @@ class Proposals extends DolibarrApi $obj = $db->fetch_object($result); $proposal_static = new Propal($db); if($proposal_static->fetch($obj->rowid)) { + // Add billing contacts ids + $proposal_static->billing_contacts_ids = $proposal_static->liste_contact(-1,'external',1,'BILLING'); $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; @@ -708,7 +713,7 @@ class Proposals extends DolibarrApi $object = parent::_cleanObjectDatas($object); - unset($object->note); + unset($object->note); unset($object->name); unset($object->lastname); unset($object->firstname); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index c0e494a1684..f345282385c 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -76,6 +76,8 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Add billing contacts ids + $this->commande->billing_contacts_ids = $this->commande->liste_contact(-1,'external',1,'BILLING'); $this->commande->fetchObjectLinked(); return $this->_cleanObjectDatas($this->commande); } @@ -159,6 +161,8 @@ class Orders extends DolibarrApi $obj = $db->fetch_object($result); $commande_static = new Commande($db); if($commande_static->fetch($obj->rowid)) { + // Add billing contacts ids + $commande_static->billing_contacts_ids = $commande_static->liste_contact(-1,'external',1,'BILLING'); $obj_ret[] = $this->_cleanObjectDatas($commande_static); } $i++; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 2c744b8bda3..8a4979b2220 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -81,6 +81,8 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Add billing contacts ids + $this->invoice->billing_contacts_ids = $this->invoice->liste_contact(-1,'external',1,'BILLING'); $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); } @@ -176,6 +178,9 @@ class Invoices extends DolibarrApi $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); + // Add billing contacts ids + $invoice_static->billing_contacts_ids = $invoice_static->liste_contact(-1,'external',1,'BILLING'); + $obj_ret[] = $this->_cleanObjectDatas($invoice_static); } $i++; From 748be12da22d57a81b0cd2c8b3de10ffbc0e6277 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Mon, 28 May 2018 09:42:24 +0200 Subject: [PATCH 2/2] Get external contacts ids instead of BILLING contacts ids. --- htdocs/comm/propal/class/api_proposals.class.php | 8 ++++---- htdocs/commande/class/api_orders.class.php | 8 ++++---- htdocs/compta/facture/class/api_invoices.class.php | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 6d5a20b60bc..d58af90d8da 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -77,8 +77,8 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // Add billing contacts ids - $this->propal->billing_contacts_ids = $this->propal->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $this->propal->contacts_ids = $this->propal->liste_contact(-1,'external',1); $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); @@ -159,8 +159,8 @@ class Proposals extends DolibarrApi $obj = $db->fetch_object($result); $proposal_static = new Propal($db); if($proposal_static->fetch($obj->rowid)) { - // Add billing contacts ids - $proposal_static->billing_contacts_ids = $proposal_static->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $proposal_static->contacts_ids = $proposal_static->liste_contact(-1,'external',1); $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index f345282385c..5f10168d33b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -76,8 +76,8 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // Add billing contacts ids - $this->commande->billing_contacts_ids = $this->commande->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $this->commande->contacts_ids = $this->commande->liste_contact(-1,'external',1); $this->commande->fetchObjectLinked(); return $this->_cleanObjectDatas($this->commande); } @@ -161,8 +161,8 @@ class Orders extends DolibarrApi $obj = $db->fetch_object($result); $commande_static = new Commande($db); if($commande_static->fetch($obj->rowid)) { - // Add billing contacts ids - $commande_static->billing_contacts_ids = $commande_static->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $commande_static->contacts_ids = $commande_static->liste_contact(-1,'external',1); $obj_ret[] = $this->_cleanObjectDatas($commande_static); } $i++; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 8a4979b2220..10cfd6bff36 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -81,8 +81,8 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // Add billing contacts ids - $this->invoice->billing_contacts_ids = $this->invoice->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $this->invoice->contacts_ids = $this->invoice->liste_contact(-1,'external',1); $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); } @@ -178,8 +178,8 @@ class Invoices extends DolibarrApi $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); - // Add billing contacts ids - $invoice_static->billing_contacts_ids = $invoice_static->liste_contact(-1,'external',1,'BILLING'); + // Add external contacts ids + $invoice_static->contacts_ids = $invoice_static->liste_contact(-1,'external',1); $obj_ret[] = $this->_cleanObjectDatas($invoice_static); }