diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 70309a0428d..8f08f1c1d2f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -90,6 +90,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer'); + /* * Actions @@ -106,7 +108,7 @@ if (empty($reshook)) { exit; } - if ($action == "confirm_update") { + if ($action == "confirm_update" && $permissiontoadd) { $error = 0; if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { @@ -162,7 +164,7 @@ if (empty($reshook)) { } } } - } elseif ($action == "add") { + } elseif ($action == "add" && $permissiontoadd) { $error = 0; if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { @@ -221,7 +223,7 @@ if (empty($reshook)) { $action = ''; } } - } elseif ($action == "confirm_delete") { + } elseif ($action == "confirm_delete" && $permissiontoadd) { $object = new BookKeeping($db); $result = $object->fetch($id, null, $mode); @@ -238,7 +240,7 @@ if (empty($reshook)) { } } $action = ''; - } elseif ($action == "confirm_create") { + } elseif ($action == "confirm_create" && $permissiontoadd) { $error = 0; $object = new BookKeeping($db); @@ -287,7 +289,7 @@ if (empty($reshook)) { } } - if ($action == 'setdate') { + if ($action == 'setdate' && $permissiontoadd) { $datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); $result = $object->updateByMvt($piece_num, 'doc_date', $db->idate($datedoc), $mode); if ($result < 0) { @@ -300,7 +302,7 @@ if (empty($reshook)) { } } - if ($action == 'setjournal') { + if ($action == 'setjournal' && $permissiontoadd) { $result = $object->updateByMvt($piece_num, 'code_journal', $journal_code, $mode); $result = $object->updateByMvt($piece_num, 'journal_label', $journal_label, $mode); if ($result < 0) { @@ -313,7 +315,7 @@ if (empty($reshook)) { } } - if ($action == 'setdocref') { + if ($action == 'setdocref' && $permissiontoadd) { $refdoc = GETPOST('doc_ref', 'alpha'); $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); if ($result < 0) { @@ -327,7 +329,7 @@ if (empty($reshook)) { } // Validate transaction - if ($action == 'valid') { + if ($action == 'valid' && $permissiontoadd) { $result = $object->transformTransaction(0, $piece_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -338,9 +340,12 @@ if (empty($reshook)) { } } + + /* * View */ + $form = new Form($db); $formaccounting = new FormAccounting($db); @@ -460,12 +465,16 @@ if ($action == 'create') { print $langs->trans('Docdate'); print ''; if ($action != 'editdate') { - print '