Merge pull request #11028 from aspangaro/10.0_accounting6

NEW Accounting - Add rights on export, delete operations in ledger
This commit is contained in:
Laurent Destailleur 2019-06-24 19:59:18 +02:00 committed by GitHub
commit d075f42d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 28 deletions

View File

@ -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.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$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 '<td class="nowraponall center">';
if(empty($line->date_export)) {
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . urlencode($line->piece_num) . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . urlencode($line->piece_num) . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
if (empty($line->date_export)) {
if ($user->rights->accounting->mouvements->creer) {
print '<a href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
}
if ($user->rights->accounting->mouvements->supprimer) {
print '&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_delete() . '</a>';
}
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
@ -855,10 +861,11 @@ print "</table>";
print '</div>';
// TODO Replace this with mass delete action
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DeleteMvt") . '</a>';
print '</div>';
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<a class="butActionDelete" name="button_delmvt" href="' . $_SERVER["PHP_SELF"] . '?action=delbookkeepingyear' . ($param ? '&' . $param : '') . '">' . $langs->trans("DeleteMvt") . '</a>';
print '</div>';
}
print '</form>';

View File

@ -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
//-------

View File

@ -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