diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php
index 4ad110f2f72..962f943c0ad 100644
--- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php
+++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php
@@ -119,6 +119,12 @@ class UserRightsToFunction extends AbstractRector
if (!$node->var instanceof Node\Expr\PropertyFetch) {
return null;
}
+ // Add a test to avoid rector error on html.formsetup.class.php
+ if (! $node->name instanceof Node\Expr\Variable && is_null($this->getName($node))) {
+ //var_dump($node);
+ return null;
+ //exit;
+ }
$perm1 = $node->name instanceof Node\Expr\Variable ? $node->name : new String_($this->getName($node));
$moduleNode = $node->var;
if (!$moduleNode instanceof Node\Expr\PropertyFetch) {
diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php
index 9e2ee440926..060999775b1 100644
--- a/htdocs/contrat/agenda.php
+++ b/htdocs/contrat/agenda.php
@@ -165,8 +165,8 @@ if ($object->id > 0) {
if (!empty($modCodeContract->code_auto)) {
$morehtmlref .= $object->ref;
} else {
- $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
- $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
+ $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3);
+ $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2);
}
$permtoedit = 0;
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 46248615e12..d2fac53a84b 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -605,7 +605,7 @@ if (empty($reshook)) {
$info_bits |= 0x01;
}
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance))
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->hasRight('produit', 'ignore_price_min_advance'))
|| empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
$object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
$result = -1;
@@ -1388,18 +1388,18 @@ if ($action == 'create') {
if (!empty($modCodeContract->code_auto)) {
$morehtmlref .= $object->ref;
} else {
- $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
- $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
+ $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3);
+ $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2);
}
$morehtmlref .= '
';
// Ref customer
- $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1, 'getFormatedCustomerRef');
+ $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->hasRight('contrat', 'creer'), 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1, 'getFormatedCustomerRef');
// Ref supplier
$morehtmlref .= '
';
- $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
+ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->hasRight('contrat', 'creer'), 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
// Thirdparty
$morehtmlref .= '
'.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
@@ -1456,9 +1456,9 @@ if ($action == 'create') {
// Date
print '
';
print '| ';
- print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, $user->rights->contrat->creer);
+ print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, $user->hasRight('contrat', 'creer'));
print ' | ';
- print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, $user->rights->contrat->creer, 'datehourpicker');
+ print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, $user->hasRight('contrat', 'creer'), 'datehourpicker');
print ' | ';
print '
';
@@ -1561,7 +1561,7 @@ if ($action == 'create') {
}
//
- if ($nbofservices > 1 && $conf->browser->layout != 'phone' && !empty($user->rights->contrat->creer)) {
+ if ($nbofservices > 1 && $conf->browser->layout != 'phone' && $user->hasRight('contrat', 'creer')) {
print '
';
if ($cursorline > 1) {
print 'id.'&action=up&token='.newToken().'&rowid='.$objp->rowid.'">';
@@ -1652,18 +1652,18 @@ if ($action == 'create') {
// Icon move, update et delete (status contract 0=draft,1=validated,2=closed)
print ' | ';
- if ($user->rights->contrat->creer && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->statut >= 0)) {
+ if ($user->hasRight('contrat', 'creer') && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->statut >= 0)) {
print '';
print '';
print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow');
print '';
}
- if ($user->rights->contrat->creer && ($object->statut >= 0)) {
+ if ($user->hasRight('contrat', 'creer') && ($object->statut >= 0)) {
print '';
print img_edit();
print '';
}
- if ($user->rights->contrat->creer && ($object->statut >= 0)) {
+ if ($user->hasRight('contrat', 'creer') && ($object->statut >= 0)) {
print '';
print img_delete();
print '';
@@ -1903,7 +1903,7 @@ if ($action == 'create') {
$tmpactionpicto = 'playstop';
$tmpactiontext = $langs->trans("Disable");
}
- if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) {
+ if (($tmpaction == 'activateline' && $user->hasRight('contrat', 'activer')) || ($tmpaction == 'unactivateline' && $user->hasRight('contrat', 'desactiver'))) {
print 'id.'&ligne='.$object->lines[$cursorline - 1]->id.'&action='.$tmpaction.'">';
print img_picto($tmpactiontext, $tmpactionpicto);
print '';
@@ -1950,7 +1950,7 @@ if ($action == 'create') {
}
// Form to activate line
- if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) {
+ if ($user->hasRight('contrat', 'activer') && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) {
print '';
}
- if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) {
+ if ($user->hasRight('contrat', 'activer') && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) {
/**
* Disable a contract line
*/
@@ -2070,7 +2070,7 @@ if ($action == 'create') {
print '';
// Form to add new line
- if ($user->rights->contrat->creer && ($object->statut == 0)) {
+ if ($user->hasRight('contrat', 'creer') && ($object->statut == 0)) {
$dateSelector = 1;
print "\n";
@@ -2134,7 +2134,7 @@ if ($action == 'create') {
// Send
if (empty($user->socid)) {
if ($object->status == $object::STATUS_VALIDATED) {
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) {
+ if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('contrat', 'creer'))) {
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', true, $params);
} else {
print dolGetButtonAction('', $langs->trans('SendMail'), 'default', '#', '', false, $params);
@@ -2143,7 +2143,7 @@ if ($action == 'create') {
}
if ($object->status == $object::STATUS_DRAFT && $nbofservices) {
- if ($user->rights->contrat->creer) {
+ if ($user->hasRight('contrat', 'creer')) {
print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken(), '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
@@ -2151,7 +2151,7 @@ if ($action == 'create') {
}
}
if ($object->status == $object::STATUS_VALIDATED) {
- if ($user->rights->contrat->creer) {
+ if ($user->hasRight('contrat', 'creer')) {
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
@@ -2182,14 +2182,14 @@ if ($action == 'create') {
}
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) {
- if ($user->rights->contrat->activer) {
+ if ($user->hasRight('contrat', 'activer')) {
print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=activate&token='.newToken(), '', true, $params);
} else {
print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', '#', '', false, $params);
}
}
if ($object->nbofservicesclosed < $nbofservices) {
- if ($user->rights->contrat->desactiver) {
+ if ($user->hasRight('contrat', 'desactiver')) {
print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', true, $params);
} else {
print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', '#', '', false, $params);
@@ -2213,7 +2213,7 @@ if ($action == 'create') {
}
// Clone
- if ($user->rights->contrat->creer) {
+ if ($user->hasRight('contrat', 'creer')) {
print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', true, $params);
}
@@ -2341,5 +2341,5 @@ $(document).ready(function() {
}
});
- global->CONTRACT_ADDON)) {
$mybool = false;
- $file = $conf->global->CONTRACT_ADDON.".php";
+ $file = getDolGlobalString('CONTRACT_ADDON') . ".php";
$classname = $conf->global->CONTRACT_ADDON;
// Include file with class
@@ -2272,7 +2272,7 @@ class Contrat extends CommonObject
$this->from = " FROM ".MAIN_DB_PREFIX."contrat as c";
$this->from .= ", ".MAIN_DB_PREFIX."contratdet as cd";
$this->from .= ", ".MAIN_DB_PREFIX."societe as s";
- if (empty($user->rights->societe->client->voir) && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
$this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
@@ -2303,7 +2303,7 @@ class Contrat extends CommonObject
if ($user->socid) {
$sql .= " AND c.fk_soc = ".((int) $user->socid);
}
- if (empty($user->rights->societe->client->voir) && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
@@ -2371,7 +2371,7 @@ class Contrat extends CommonObject
$sql = "SELECT count(c.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
- if (empty($user->rights->societe->client->voir) && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".((int) $user->id);
$clause = "AND";
@@ -2628,14 +2628,14 @@ class Contrat extends CommonObject
}
}
- if (empty($conf->global->CONTRACT_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.".php")) {
+ if (empty($conf->global->CONTRACT_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/contract/" . getDolGlobalString('CONTRACT_ADDON').".php")) {
$this->error = 'ErrorSetupNotComplete';
dol_syslog($this->error);
return -1;
}
// Set ref
- require_once DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.'.php';
+ require_once DOL_DOCUMENT_ROOT."/core/modules/contract/" . getDolGlobalString('CONTRACT_ADDON').'.php';
$obj = $conf->global->CONTRACT_ADDON;
$modContract = new $obj();
$clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj);
diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php
index 0c8940e46e2..98fd9cd1e5f 100644
--- a/htdocs/contrat/index.php
+++ b/htdocs/contrat/index.php
@@ -95,7 +95,7 @@ $vals = array();
$sql = "SELECT count(cd.rowid) as nb, cd.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
@@ -104,7 +104,7 @@ $sql .= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) {
$sql .= ' AND c.fk_soc = '.((int) $user->socid);
}
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " GROUP BY cd.statut";
@@ -132,7 +132,7 @@ if ($resql) {
$sql = "SELECT count(cd.rowid) as nb, cd.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
@@ -141,7 +141,7 @@ $sql .= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) {
$sql .= ' AND c.fk_soc = '.((int) $user->socid);
}
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " GROUP BY cd.statut";
@@ -243,13 +243,13 @@ if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) {
$sql = "SELECT c.rowid, c.ref,";
$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.rowid = c.fk_soc";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut = 0";
- if (empty($user->rights->societe->client->voir) && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
@@ -320,7 +320,7 @@ $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,';
$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut,";
$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
}
$sql .= " ".MAIN_DB_PREFIX."contrat as c";
@@ -328,7 +328,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contra
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut > 0";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
@@ -410,7 +410,7 @@ $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fou
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
@@ -418,7 +418,7 @@ $sql .= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
@@ -502,7 +502,7 @@ $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fou
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
@@ -512,7 +512,7 @@ $sql .= " AND c.statut = 1";
$sql .= " AND cd.statut = 0";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
@@ -595,7 +595,7 @@ $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fou
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
@@ -606,7 +606,7 @@ $sql .= " AND cd.statut = 4";
$sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 15875936e6c..aa101a80395 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -321,7 +321,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
-if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
+if ($search_sale > 0 || (!$user->hasRight('societe', 'client', 'voir') && !$socid)) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
@@ -341,7 +341,7 @@ if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
-if (empty($user->rights->societe->client->voir) && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($search_date_start) {
@@ -737,7 +737,7 @@ if (!empty($socid)) {
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
-$newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer);
+$newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('contrat', 'creer'));
print ' |