diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 4fc30bb0c30..0c92bcb8950 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -104,7 +104,7 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
-if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int'))
+if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
{
if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
{
@@ -300,7 +300,7 @@ if (! empty($search_lettering_code)) {
}
-if ($action == 'delbookkeeping') {
+if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
@@ -315,7 +315,7 @@ if ($action == 'delbookkeeping') {
exit;
}
}
-if ($action == 'delbookkeepingyearconfirm') {
+if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delyear = GETPOST('delyear', 'int');
if ($delyear==-1) {
@@ -346,7 +346,7 @@ if ($action == 'delbookkeepingyearconfirm') {
setEventMessages("NoRecordDeleted", null, 'warnings');
}
}
-if ($action == 'delmouvconfirm') {
+if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
@@ -366,7 +366,8 @@ if ($action == 'delmouvconfirm') {
}
// Export into a file with format defined into setup (FEC, CSV, ...)
-if ($action == 'export_file') {
+if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
+
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
if ($result < 0)
@@ -514,11 +515,11 @@ if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
}
$newcardbutton.= ''.$langs->trans("IncludeDocsAlreadyExported").'';
-$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''));
+$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export);
$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
-$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
+$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
@@ -818,12 +819,17 @@ if ($num > 0)
// Action column
print '
';
- if(empty($line->date_export)) {
- print '' . img_edit() . ' ';
- print '' . img_delete() . '';
+ if (empty($line->date_export)) {
+ if ($user->rights->accounting->mouvements->creer) {
+ print '' . img_edit() . '';
+ }
+ if ($user->rights->accounting->mouvements->supprimer) {
+ print ' ' . img_delete() . '';
+ }
}
- print ' | ';
- if (! $i) $totalarray['nbfield']++;
+ print '';
+
+ if (! $i) $totalarray['nbfield']++;
print "\n";
@@ -855,10 +861,11 @@ print "";
print '';
// TODO Replace this with mass delete action
-print '';
-
+if ($user->rights->accounting->mouvements->supprimer_tous) {
+ print '';
+}
print '';
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 65638a1cab2..c58ba79a8c4 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -170,15 +170,23 @@ class modAccounting extends DolibarrModules
$this->rights = array(); // Permission array used by this module
$r = 0;
- $this->rights[$r][0] = 50440;
- $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';
+ $this->rights[$r][0] = 50440;
+ $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';
+ $this->rights[$r][2] = 'r';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'chartofaccount';
+ $this->rights[$r][5] = '';
+ $r++;
+
+ $this->rights[$r][0] = 50430;
+ $this->rights[$r][1] = 'Define and close a fiscal year';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'chartofaccount';
+ $this->rights[$r][4] = 'fiscalyear';
$this->rights[$r][5] = '';
$r++;
- $this->rights[$r][0] = 50401;
+ $this->rights[$r][0] = 50401;
$this->rights[$r][1] = 'Bind products and invoices with accounting accounts';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
@@ -212,6 +220,30 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'creer';
$r++;
+ $this->rights[$r][0] = 50414;
+ $this->rights[$r][1] = 'Delete operations in Ledger';
+ $this->rights[$r][2] = 'd';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'supprimer';
+ $r++;
+
+ $this->rights[$r][0] = 50415;
+ $this->rights[$r][1] = 'Delete all operations by year and journal in Ledger';
+ $this->rights[$r][2] = 'd';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'supprimer_tous';
+ $r++;
+
+ $this->rights[$r][0] = 50418;
+ $this->rights[$r][1] = 'Export operations of the Ledger';
+ $this->rights[$r][2] = 'r';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'export';
+ $r++;
+
$this->rights[$r][0] = 50420;
$this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)';
$this->rights[$r][2] = 'r';
@@ -220,14 +252,6 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'lire';
$r++;
- $this->rights[$r][0] = 50430;
- $this->rights[$r][1] = 'Define and close a fiscal year';
- $this->rights[$r][2] = 'r';
- $this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'fiscalyear';
- $this->rights[$r][5] = '';
- $r++;
-
// Menus
//-------
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 76631626eeb..b8cab5ce713 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -907,6 +907,9 @@ Permission50202=Import transactions
Permission50401=Bind products and invoices with accounting accounts
Permission50411=Read operations in ledger
Permission50412=Write/Edit operations in ledger
+Permission50414=Delete operations in ledger
+Permission50415=Delete all operations by year and journal in ledger
+Permission50418=Export operations of the ledger
Permission50420=Report and export reports (turnover, balance, journals, ledger)
Permission50430=Define and close a fiscal year
Permission50440=Manage chart of accounts, setup of accountancy