From 7ad2fda289ec5d511b7d622b930106934962755a Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 22 Sep 2016 15:06:39 +0200 Subject: [PATCH 1/3] NEW : Reopen a paid bill is a user right --- htdocs/compta/facture.php | 2 +- htdocs/core/modules/modFacture.class.php | 7 +++++++ htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 961d133e88e..c421bb7f41a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3925,7 +3925,7 @@ else if ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data - && $user->rights->facture->creer) // A paid invoice (partially or completely) + && $user->rights->facture->reopen) // A paid invoice (partially or completely) { if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index d15215a4f99..fd0832f9c9d 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -183,6 +183,13 @@ class modFacture extends DolibarrModules $this->rights[$r][4] = 'facture'; $this->rights[$r][5] = 'export'; + $r++; + $this->rights[$r][0] = 1322; + $this->rights[$r][1] = 'Rouvrir une facture totalement réglée'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'reopen'; + // Exports //-------- diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0ab14c4218b..f06c5985220 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -751,6 +751,7 @@ Permission1236=Export supplier invoices, attributes and payments Permission1237=Export supplier orders and their details Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments +Permission1322=Reopen a paid bill Permission1421=Export customer orders and attributes Permission20001=Read leave requests (yours and your subordinates) Permission20002=Create/modify your leave requests From ad03bdf3b9768da3f166b52ae828608c970f9671 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 26 Sep 2016 17:39:46 +0200 Subject: [PATCH 2/3] FIX : reopen invoice is an advanced right and default value is 1 --- htdocs/compta/facture.php | 2 +- htdocs/core/modules/modFacture.class.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c421bb7f41a..48d5a01930b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3925,7 +3925,7 @@ else if ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data - && $user->rights->facture->reopen) // A paid invoice (partially or completely) + && $user->rights->facture->creer && $user->rights->facture->invoice_advance->reopen) // A paid invoice (partially or completely) { if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index fd0832f9c9d..1d9cde757f1 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -187,8 +187,9 @@ class modFacture extends DolibarrModules $this->rights[$r][0] = 1322; $this->rights[$r][1] = 'Rouvrir une facture totalement réglée'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'reopen'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'invoice_advance'; + $this->rights[$r][5] = 'reopen'; // Exports From 03d126810cf34e80283b1688558aa4a1745a2dd6 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 29 Sep 2016 10:15:34 +0200 Subject: [PATCH 3/3] FIX : "reopen " new right must respect advanced user rights management --- htdocs/compta/facture.php | 2 +- htdocs/core/modules/modFacture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 48d5a01930b..9e76b37c8ce 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3925,7 +3925,7 @@ else if ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data - && $user->rights->facture->creer && $user->rights->facture->invoice_advance->reopen) // A paid invoice (partially or completely) + && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->invoice_advance->reopen))) // A paid invoice (partially or completely) { if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 1d9cde757f1..8d268728d35 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -187,7 +187,7 @@ class modFacture extends DolibarrModules $this->rights[$r][0] = 1322; $this->rights[$r][1] = 'Rouvrir une facture totalement réglée'; $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; + $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; $this->rights[$r][5] = 'reopen';