Laurent Destailleur 3 年 前
コミット
0104f00a7a
1 ファイル変更16 行追加8 行削除
  1. 16 8
      htdocs/fourn/product/list.php

+ 16 - 8
htdocs/fourn/product/list.php

@@ -33,10 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
 
 $langs->loadLangs(array("products", "suppliers"));
 
-if (!$user->rights->produit->lire && !$user->rights->service->lire) {
-	accessforbidden();
-}
-
 $sref = GETPOST('sref', 'alphanohtml');
 $sRefSupplier = GETPOST('srefsupplier');
 $snom = GETPOST('snom', 'alphanohtml');
@@ -72,13 +68,15 @@ $catid = GETPOST('catid', 'intcomma');
 $hookmanager->initHooks(array('supplierpricelist'));
 $extrafields = new ExtraFields($db);
 
+if (empty($user->rights->produit->lire) && empty($user->rights->service->lire)) {
+	accessforbidden();
+}
 
+$permissiontoadd = ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'));
 
 
 /*
- * ACTIONS
- *
- * Put here all code to do according to value of "action" parameter
+ * Actions
  */
 
 if (GETPOST('cancel', 'alpha')) {
@@ -228,7 +226,11 @@ if ($resql) {
 	if ($optioncss != '') {
 		$param .= '&optioncss='.$optioncss;
 	}
-	print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
+
+	$newcardbutton = '';
+	$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/list.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
+
+	print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton);
 
 	if (!empty($catid)) {
 		print "<div id='ways'>";
@@ -358,6 +360,12 @@ if ($resql) {
 	}
 	$db->free($resql);
 
+	// If no record found
+	if ($num == 0) {
+		$colspan = 8;
+		print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
+	}
+
 	print "</table></div>";
 
 	print '</form>';