diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 057e2f0484c..fce8b5b6a7f 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -43,13 +43,13 @@ $rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel');
// Security check
-if (! $user->admin)
- accessforbidden();
+
$object = new AccountingAccount($db);
// Action
-if ($action == 'add') {
+if ($action == 'add' && $user->rights->accounting->chartofaccount)
+{
if (! $cancel) {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
@@ -97,7 +97,7 @@ if ($action == 'add') {
}
header("Location: account.php");
exit;
-} else if ($action == 'edit') {
+} else if ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (! $cancel) {
$result = $object->fetch($id);
@@ -145,7 +145,7 @@ if ($action == 'add') {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
}
-} else if ($action == 'delete') {
+} else if ($action == 'delete' && $user->rights->accounting->chartofaccount) {
$result = $object->fetch($id);
if (! empty($object->id)) {
@@ -329,14 +329,14 @@ if ($action == 'create') {
print '
' . $object->pcg_subtype . ' | ';
// Active
- print '| ' . $langs->trans("Activated") . ' | ';
+ print '
| ' . $langs->trans("Status") . ' | ';
print '';
-
- if (empty($object->active)) {
+ print $object->getLibStatut(4);
+ /*if (empty($object->active)) {
print img_picto($langs->trans("Disabled"), 'switch_off');
} else {
print img_picto($langs->trans("Activated"), 'switch_on');
- }
+ }*/
print ' |
';
@@ -350,13 +350,13 @@ if ($action == 'create') {
print '';
- if ($user->admin) {
+ if (! empty($user->rights->accounting->chartofaccount)) {
print '
' . $langs->trans('Modify') . '';
} else {
print '
' . $langs->trans('Modify') . '';
}
- if ($user->admin) {
+ if (! empty($user->rights->accounting->chartofaccount)) {
print '
' . $langs->trans('Delete') . '';
} else {
print '
' . $langs->trans('Delete') . '';
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 690f3785df1..00a16a227e3 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -45,7 +45,8 @@ class AccountingAccount extends CommonObject
var $label;
var $fk_user_author;
var $fk_user_modif;
- var $active;
+ var $active; // duplicate with status
+ var $status;
/**
* Constructor
@@ -103,6 +104,7 @@ class AccountingAccount extends CommonObject
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active;
+ $this->status = $obj->active;
return $this->id;
} else {
@@ -465,4 +467,61 @@ class AccountingAccount extends CommonObject
return - 1;
}
}
+
+
+ /**
+ * Retourne le libelle du statut d'un user (actif, inactif)
+ *
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function getLibStatut($mode=0)
+ {
+ return $this->LibStatut($this->status,$mode);
+ }
+
+ /**
+ * Renvoi le libelle d'un statut donne
+ *
+ * @param int $statut Id statut
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function LibStatut($statut,$mode=0)
+ {
+ global $langs;
+ $langs->load('users');
+
+ if ($mode == 0)
+ {
+ $prefix='';
+ if ($statut == 1) return $langs->trans('Enabled');
+ if ($statut == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 1)
+ {
+ if ($statut == 1) return $langs->trans('Enabled');
+ if ($statut == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 2)
+ {
+ if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 3)
+ {
+ if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4');
+ if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5');
+ }
+ if ($mode == 4)
+ {
+ if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 5)
+ {
+ if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
+ if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+ }
+ }
}