From 712e1c4e7c27643b6584526b0705ba776fb8c728 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sat, 17 Apr 2021 01:06:30 +0200 Subject: [PATCH 1/3] NEW Edit sales lines rights in TakePOS --- htdocs/core/modules/modTakePos.class.php | 14 ++++++++++++++ htdocs/langs/en_US/admin.lang | 2 ++ htdocs/takepos/invoice.php | 9 ++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index d34213f062c..7a1384a2de5 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -202,6 +202,20 @@ class modTakePos extends DolibarrModules $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; + + $r++; + $this->rights[$r][0] = 50152; + $this->rights[$r][1] = 'Edit sales lines'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'editlines'; + + $r++; + $this->rights[$r][0] = 50153; + $this->rights[$r][1] = 'Edit ordered sales lines'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'editorderedlines'; // Main menu entries diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b103d0082ba..d81b2fc6e9d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -964,6 +964,8 @@ Permission23003=Delete Scheduled job Permission23004=Execute Scheduled job Permission50101=Use Point of Sale (SimplePOS) Permission50151=Use Point of Sale (TakePOS) +Permission50152=Edit sales lines +Permission50153=Edit ordered sales lines Permission50201=Read transactions Permission50202=Import transactions Permission50330=Read objects of Zapier diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c7a01e5d8bc..273d8ec5a6b 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -631,7 +631,8 @@ if ($action == "delete") { if ($action == "updateqty") { foreach ($invoice->lines as $line) { if ($line->id == $idline) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } @@ -653,7 +654,8 @@ if ($action == "updateprice") { if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } @@ -675,7 +677,8 @@ if ($action == "updatereduction") { if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->multicurrency_subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } From 83da58b85f4d5c33d82c259d5ebbd18c98eb3e33 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 17 Apr 2021 01:17:48 +0200 Subject: [PATCH 2/3] Fix travis --- htdocs/core/modules/modTakePos.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 7a1384a2de5..84810e80a53 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -202,14 +202,14 @@ class modTakePos extends DolibarrModules $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; - + $r++; $this->rights[$r][0] = 50152; $this->rights[$r][1] = 'Edit sales lines'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'editlines'; - + $r++; $this->rights[$r][0] = 50153; $this->rights[$r][1] = 'Edit ordered sales lines'; From d5c737ddb6b069fd655caa3f3332df0d0c8cecfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 17:19:28 +0200 Subject: [PATCH 3/3] Update modTakePos.class.php --- htdocs/core/modules/modTakePos.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 84810e80a53..5cb7a7f0c38 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -198,21 +198,21 @@ class modTakePos extends DolibarrModules $r++; $this->rights[$r][0] = 50151; - $this->rights[$r][1] = 'Use Point Of Sale'; + $this->rights[$r][1] = 'Use Point Of Sale (record a sale, add products, record payment)'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; $r++; $this->rights[$r][0] = 50152; - $this->rights[$r][1] = 'Edit sales lines'; + $this->rights[$r][1] = 'Can modify added sales lines (prices, discount)'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'editlines'; $r++; $this->rights[$r][0] = 50153; - $this->rights[$r][1] = 'Edit ordered sales lines'; + $this->rights[$r][1] = 'Edit ordered sales lines (useful only when option "Order printers" has been enabled). Allow to edit sales lines even after the order has been printed'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'editorderedlines';