From e85b4a5a207fa9f9dd3f78ec72346e2539a34c50 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 16 Apr 2020 12:15:41 +0200 Subject: [PATCH 1/4] FIX Directory Issue with Multicompany Before : Cannot show documents added entity who created the product/service Now : show all files. Warning : all products must be generated in $object->entity directory and not in $conf->entity. --- htdocs/product/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ad793f4f7d3..499ac1ec1e4 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2255,7 +2255,11 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') // Documents $objectref = dol_sanitizeFileName($object->ref); $relativepath = $comref.'/'.$objectref.'.pdf'; - $filedir = $conf->product->dir_output.'/'.$objectref; + if ($conf->product->entity != $object->entity) { + $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities + } else { + $filedir = $conf->product->dir_output.'/'.$objectref; //Check repertory of the current product + } $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; From 19c85785f7d049f4b4e8002d1291738482ceec1b Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 16 Apr 2020 13:26:55 +0200 Subject: [PATCH 2/4] Fix --- htdocs/product/card.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 499ac1ec1e4..de863769519 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -18,6 +18,7 @@ * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2019 Frédéric France * Copyright (C) 2019-2020 Thibault FOUCART + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -2255,11 +2256,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') // Documents $objectref = dol_sanitizeFileName($object->ref); $relativepath = $comref.'/'.$objectref.'.pdf'; - if ($conf->product->entity != $object->entity) { - $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities - } else { - $filedir = $conf->product->dir_output.'/'.$objectref; //Check repertory of the current product - } + $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; From 68ccbac49c09362d9fe09b3bd28505c12268fc80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 19 Sep 2020 22:35:33 +0200 Subject: [PATCH 3/4] Update api_orders.class.php --- htdocs/commande/class/api_orders.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index f62c00ee81b..d89c2770f64 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -545,8 +545,9 @@ class Orders extends DolibarrApi * * @param int $id Id of order to update * @param int $rowid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). * - * @url DELETE {id}/contact/{rowid} + * @url DELETE {id}/contact/{rowid}/{type} * * @return int * @@ -554,7 +555,7 @@ class Orders extends DolibarrApi * @throws RestException 404 * @throws RestException 500 */ - public function deleteContact($id, $rowid) + public function deleteContact($id, $rowid, $type) { if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -569,10 +570,16 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->delete_linked_contact($rowid); + $contacts = $this->commande->liste_contact(); - if (!$result) { - throw new RestException(500, 'Error when deleted the contact'); + foreach ($contacts as $contact) { + if ($contact['id'] == $rowid && $contact['code'] == $type) { + $result = $this->commande->delete_contact($contact['rowid']); + + if (!$result) { + throw new RestException(500, 'Error when deleted the contact'); + } + } } return array( From 3bc9c49307d1e2cfcc6e54d72c0ee277a26c4dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 28 Sep 2020 16:57:30 +0200 Subject: [PATCH 4/4] Update api_orders.class.php --- htdocs/commande/class/api_orders.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index d89c2770f64..4c3def4b796 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -547,7 +547,7 @@ class Orders extends DolibarrApi * @param int $rowid Row key of the contact in the array contact_ids. * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). * - * @url DELETE {id}/contact/{rowid}/{type} + * @url DELETE {id}/contact/{contactid}/{type} * * @return int * @@ -555,7 +555,7 @@ class Orders extends DolibarrApi * @throws RestException 404 * @throws RestException 500 */ - public function deleteContact($id, $rowid, $type) + public function deleteContact($id, $contactid, $type) { if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -573,7 +573,7 @@ class Orders extends DolibarrApi $contacts = $this->commande->liste_contact(); foreach ($contacts as $contact) { - if ($contact['id'] == $rowid && $contact['code'] == $type) { + if ($contact['id'] == $contactid && $contact['code'] == $type) { $result = $this->commande->delete_contact($contact['rowid']); if (!$result) {