diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 1e4c4d2e78a..b4e1f19554e 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1821,8 +1821,9 @@ if ($resql) {
$total_ht = 0;
$total_margin = 0;
+ $imaxinloop = ($limit ? min($num, $limit) : $num);
$last_num = min($num, $limit);
- while ($i < $last_num) {
+ while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
$notshippable = 0;
@@ -2457,6 +2458,17 @@ if ($resql) {
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+ // If no record found
+ if ($num == 0) {
+ $colspan = 1;
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
+ print '
| '.$langs->trans("NoRecordFound").' |
';
+ }
+
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index cc8bae4d907..22c4921b5b1 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -209,6 +209,12 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
$error = 0;
+$permissiontoread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
+$permissiontoadd = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
+$permissiontodelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer);
+$permissiontovalidate = $permissiontoadd;
+$permissiontoapprove = ($user->rights->fournisseur->commande->approuver || $user->rights->supplier_order->approuver);
+
/*
* Actions
@@ -302,9 +308,6 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'CommandeFournisseur';
$objectlabel = 'SupplierOrders';
- $permissiontoread = $user->rights->fournisseur->commande->lire;
- $permissiontodelete = $user->rights->fournisseur->commande->supprimer;
- $permissiontovalidate = $user->rights->fournisseur->commande->creer;
$uploaddir = $conf->fournisseur->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@@ -321,7 +324,7 @@ if (empty($reshook)) {
$result = $objecttmp->valid($user);
if ($result >= 0) {
// If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step
- if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
+ if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $permissiontoapprove && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1))) {
$result = $objecttmp->approve($user);
setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
} else {
@@ -1096,7 +1099,7 @@ if ($resql) {
);
if ($permissiontovalidate) {
- if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
+ if ($permissiontoapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) {
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove");
} else {
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
@@ -1106,7 +1109,7 @@ if ($resql) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
}
- if ($user->rights->fournisseur->commande->supprimer) {
+ if ($permissiontodelete) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete', 'createbills'))) {
@@ -1119,7 +1122,7 @@ if ($resql) {
$url .= '&socid='.((int) $socid);
$url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid));
}
- $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer));
+ $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissitiontoadd);
// Lines of title fields
print '