From 8d6e6e115dd7f7df3738dd858766fff8cc806548 Mon Sep 17 00:00:00 2001 From: Xebax Date: Mon, 15 Apr 2019 12:39:02 +0200 Subject: [PATCH 01/12] NEW REST API: get the list of objects in a category. --- .../categories/class/api_categories.class.php | 68 ++++++++++++++++++- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index c975236f930..9b59e1f001b 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -15,10 +15,15 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; + +require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/api_contacts.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparties.class.php'; /** * API class for categories @@ -335,4 +340,61 @@ class Categories extends DolibarrApi } return $category; } + + /** + * Get the list of objects in a category. + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $onlyids Return only ids of objects (consume less memory) + * + * @return mixed + * + * @url GET {id}/objects + */ + public function getObjects($id, $type, $onlyids = 0) + { + dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); + + if (! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + if (empty($type)) + { + throw new RestException(500, 'The "type" parameter is required.'); + } + + $result = $this->category->fetch($id); + if (! $result) { + throw new RestException(404, 'category not found'); + } + + if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->category->getObjectsInCateg($type, $onlyids); + + if ($result < 0) { + throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error); + } + + $objects = $result; + $cleaned_objects = array(); + if ($type == 'member') { + $objects_api = new Members(); + } elseif ($type == 'customer' || $type == 'supplier') { + $objects_api = new Thirdparties(); + } elseif ($type == 'product') { + $objects_api = new Products(); + } elseif ($type == 'contact') { + $objects_api = new Contacts(); + } + foreach ($objects as $obj) { + $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); + } + + return $cleaned_objects; + } } From 2bc93b9748604e474ee7d0f0e6421c424f996746 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 16 Apr 2019 16:09:16 +0200 Subject: [PATCH 02/12] NEW public note and private note in contact list sall --- htdocs/contact/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c8014e900b9..246fd172dc7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -146,6 +146,8 @@ $fieldstosearchall = array( 'p.email'=>'EMail', 's.nom'=>"ThirdParty", 'p.phone'=>"Phone", + 'p.note_public'=>"NotePublic", + 'p.note_private'=>"NotePrivate", ); // Definition of fields for list From e9b13baac2dfbc70c8a01f308d072da17c4367ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 09:27:15 +0200 Subject: [PATCH 03/12] Update mod_bom_advanced.php The property db does not exist on mod_bom_advanced. --- htdocs/core/modules/bom/mod_bom_advanced.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index 594df7e31de..ba5c437f0a0 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,11 @@ class mod_bom_advanced extends ModeleNumRefboms */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= '
'; From 9b9d4ddc4517b7b54bc42870e897ff048ec06949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 09:29:24 +0200 Subject: [PATCH 04/12] Update mod_expedition_ribera.php The property db does not exist on mod_bom_advanced. --- htdocs/core/modules/expedition/mod_expedition_ribera.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index cc7fb98baec..4ffde92649e 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,11 +60,11 @@ class mod_expedition_ribera extends ModelNumRefExpedition */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From bed3ed705c7ef5ef305191094d70dc4ad3ed6712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 09:31:53 +0200 Subject: [PATCH 05/12] Update mod_contract_magre.php The property db does not exist on mod_contract_magre. --- htdocs/core/modules/contract/mod_contract_magre.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 4a7b73cc145..1ee6d36803e 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,11 +62,11 @@ class mod_contract_magre extends ModelNumRefContracts */ public function info() { - global $conf,$langs; + global $conf,$langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From fbf718f330ce73b384b272a00e4d8ca9034dacd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 09:34:23 +0200 Subject: [PATCH 06/12] Update mod_commande_saphir.php --- .../core/modules/commande/mod_commande_saphir.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 311fd034bbd..8c96c237a0f 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,11 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From e5559ac2f9892ecdb6950472ee81d8007f0625ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 09:36:47 +0200 Subject: [PATCH 07/12] Update mod_chequereceipt_thyme.php The property db does not exist on mod_chequereceipt_thyme. --- htdocs/core/modules/cheque/mod_chequereceipt_thyme.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index d65273bd16b..7ff3bc6f6cc 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,11 +52,11 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From b05a5e49ff0d7bb67dd712a77fb80ffe9789a8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 11:39:38 +0200 Subject: [PATCH 08/12] Update export_tsv.modules.php --- htdocs/core/modules/export/export_tsv.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index f5b85c6987c..b40da3cd539 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php'; class ExportTsv extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; From 06a8513575d9daa15fac3f3f847e35b5722ef785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 11:40:59 +0200 Subject: [PATCH 09/12] Update export_excel2007new.modules.php --- htdocs/core/modules/export/export_excel2007new.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php index 29b165cb890..32b6029a294 100644 --- a/htdocs/core/modules/export/export_excel2007new.modules.php +++ b/htdocs/core/modules/export/export_excel2007new.modules.php @@ -35,7 +35,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx; class ExportExcel2007new extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; From 73b32f067933f4acb2f5f7b5e36e025c36465372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 11:41:19 +0200 Subject: [PATCH 10/12] Update export_excel2007.modules.php --- htdocs/core/modules/export/export_excel2007.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 46dc8d8fd53..e33849427b1 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class ExportExcel2007 extends ExportExcel { /** - * @var int ID + * @var string ID */ public $id; From a0ce52bb2388f83ec0c8160146fc734607b6eaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 11:41:37 +0200 Subject: [PATCH 11/12] Update export_excel.modules.php --- htdocs/core/modules/export/export_excel.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 5b8accdae1a..3eafc454530 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class ExportExcel extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; From 53c851de7b1e2df8a65f5c90b824a45405acd3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2019 11:42:25 +0200 Subject: [PATCH 12/12] Update export_csv.modules.php --- htdocs/core/modules/export/export_csv.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 79ec096b8de..c3c8431962e 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -33,7 +33,7 @@ set_time_limit(0); class ExportCsv extends ModeleExports { /** - * @var int ID + * @var string ID ex: csv, tsv, excel... */ public $id;