From 660a1cea1d8ddca131114ec2c7c975ec2bb66db2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 17 Apr 2019 07:26:39 +0200 Subject: [PATCH] NEW Accounting - Add rights on export, delete operations in ledger --- htdocs/accountancy/bookkeeping/list.php | 61 +++++++++++++-------- htdocs/core/modules/modAccounting.class.php | 39 ++++++++++--- htdocs/langs/en_US/admin.lang | 9 +++ 3 files changed, 79 insertions(+), 30 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 207ea3464d8..53603e08b39 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018 Frédéric France * @@ -100,7 +100,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')) { @@ -283,7 +283,7 @@ if (! empty($search_lettering_code)) { } -if ($action == 'delbookkeeping') { +if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { $import_key = GETPOST('importkey', 'alpha'); @@ -296,7 +296,7 @@ if ($action == 'delbookkeeping') { exit(); } } -if ($action == 'delbookkeepingyearconfirm') { +if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { $delyear = GETPOST('delyear', 'int'); if ($delyear==-1) { @@ -327,7 +327,7 @@ if ($action == 'delbookkeepingyearconfirm') { exit; } } -if ($action == 'delmouvconfirm') { +if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { $mvt_num = GETPOST('mvt_num', 'int'); @@ -347,7 +347,7 @@ 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); @@ -442,18 +442,30 @@ print ''; print ''; print ''; -$listofformat=AccountancyExport::getType(); -$button = ''; -if (count($filter)) $button.= $langs->trans("ExportFilteredList"); -else $button.= $langs->trans("ExportList"); -//$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')'; -$button.= ''; - +if ($user->rights->accounting->mouvements->export) { + $listofformat=AccountancyExport::getType(); + $button = ''; + if (count($filter)) $button.= $langs->trans("ExportFilteredList"); + else $button.= $langs->trans("ExportList"); + $button.= ''; +} else { + $button = ''; + if (count($filter)) $button.= $langs->trans("ExportFilteredList"); + else $button.= $langs->trans("ExportList"); + $button.= ''; +} $groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; -$newcardbutton = ''.$langs->trans("NewAccountingMvt").''; -$newcardbutton.= ''; -$newcardbutton.= ''; + +if ($user->rights->accounting->mouvements->creer) { + $newcardbutton = ''.$langs->trans("NewAccountingMvt").''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} else { + $newcardbutton = '' . $langs->trans("NewAccountingMvt") . ''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$newcardbutton, '', $limit); @@ -731,8 +743,12 @@ if ($num > 0) // Action column print ''; - print '' . img_edit() . ' '; - print '' . img_delete() . ''; + if ($user->rights->accounting->mouvements->creer) { + print '' . img_edit() . ''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print ' ' . img_delete() . ''; + } print ''; if (! $i) $totalarray['nbfield']++; @@ -766,10 +782,11 @@ print ""; print ''; // TODO Replace this with mass delete action -print '
' . "\n"; -print '' . $langs->trans("DeleteMvt") . ''; -print '
'; - +if ($user->rights->accounting->mouvements->supprimer_tous) { + print '
' . "\n"; + print '' . $langs->trans("DeleteMvt") . ''; + print '
'; +} print ''; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 8250549b9e1..c91c59169ba 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -170,14 +170,6 @@ 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][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'chartofaccount'; - $this->rights[$r][5] = ''; - $r++; - $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; @@ -212,6 +204,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'; @@ -228,6 +244,13 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = ''; $r++; + $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++; // Menus //------- diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 23f10739424..6c54cb643fe 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -882,6 +882,15 @@ Permission2802=Use FTP client in write mode (delete or upload files) Permission50101=Use Point of Sale Permission50201=Read transactions 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 Permission54001=Print Permission55001=Read polls Permission55002=Create/modify polls