Dolibarr選項卡系統

Dolibarr在由多個選項卡組成的視圖中顯示元素(發票、倉庫、用戶等)的信息。

您可以添加自己的選項卡、刪除選項卡或替換現有選項卡。

添加您自己的選項卡

1) 首先,您需要確定要添加、刪除或修改的選項卡所指向的對象類型及其代碼「objectType」。以下是完整清單:

  • 'thirdparty' --------- 要在合作方視圖中添加選項卡
  • 'intervention' ------ 要在現場服務視圖中添加選項卡
  • 'supplier_order' --- 要在供應商訂單視圖中添加選項卡
  • 'supplier_invoice' - 要在供應商發票視圖中添加選項卡
  • 'invoice' ------------- 要在客戶發票視圖中添加選項卡
  • 'order' ---------------- 要在客戶訂單視圖中添加選項卡
  • 'product' ------------- 要在產品視圖中添加選項卡
  • 'stock' ---------------- 要在庫存視圖中添加選項卡
  • 'propal' --------------- 要在報價單視圖中添加選項卡
  • 'member' ------------ 要在基金會會員視圖中添加選項卡
  • 'contract' ------------ 要在合同視圖中添加選項卡
  • 'user' ----------------- 要在用戶視圖中添加選項卡
  • 'group' --------------- 要在組視圖中添加選項卡
  • 'contact' ------------- 要在聯繫人視圖中添加選項卡
  • 'bank' ---------------- 要在銀行視圖中添加選項卡
  • 'categories_x' ------ 要在類別視圖中添加選項卡('x'的值:0=product, 1=supplier, 2=customer, 3=member)
  • 'member_stats', 'order_stats', 'supplier_order_stats', 'invoice_stats', 'supplier_invoice_stats', 'trip_stats', 'propal_stats' ------- 要在元素的統計視圖中添加選項卡
  • 'member_admin', 'company_admin', 'product_admin' --- 用於管理頁面

2) 然後添加您的選項卡,創建一個新的模塊文件。見 模塊開發

3) 然後進入描述符文件,編輯$this->tab,使用以下語法添加選項卡:

$this->tabs = array(
'objecttype:+tabname:TitleOfTab:@mymodule:$conditiontoshowtab:urloftab?id=__ID__'
);

這是一個由5或6個元素組成的字符串(取決於你是否選擇使用$conditiontoshowtab),用分隔。

這裡:

  • objecttype 是您將使用的Tab的名稱。
  • +tabname 是一個名稱來標識您的選項卡,前面是動作(+ 添加或 - 刪除,您可以刪除其他選項卡,包括默認的)。
  • TitleOfTab 是一個你選擇的標題,它將被翻譯。
  • @mymodule 是語言文件,裡面是翻譯條目。 (如: mytitlelang@mymodule 會查找 /htdocs/mymodule/langs/xx_XX/mytitlelang xx_XX 是當前語言如: en_US, fr_FR, etc.).
  • $conditiontoshowtab 是否顯示: 是真則顯示,假則不顯示。如: you can use the Dolibarr rights system, eg: $user->rights->product->creer or $user->admin or any other variable you want. 此項是可選項,跳過也是可以的。不要忘記分號也要刪除。
  • urloftab?id=__ID__ 是選項卡指向的URL。使用占位符 __ID__ 替代id。如:DOL_DOCUMENT_ROOT.'/mymodule/lib/mytab.php'

示例:

$this->tabs = array(
'product:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__',     // To add a new tab identified by code tabname1 in objecttype product (Products/Services)
'product:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__',  // To add another new tab identified by code tabname2 in objecttype product (Products/Services)
);

4) 激活此模塊

5) 測試在對象頁面中的新選項卡是否出現,連結是否能正確打開頁面

刪除現有選項卡

該過程與添加選項卡的過程相同,但在描述符文件的 $this->tabs 數組中使用以下語法:

$this->tabs = array(
'objecttype:-tabnametobedeleted'
);                                                     // To remove an existing tab identified by code tabnametobedeleted

注意:在這種情況下不需要其他參數。

要查找現有選項卡的「tabname」名稱,請參閱相應「core/lib/module.lib.php」文件的「product_prepare_head」函數中使用的名稱,其位於「$head[$h][2]」部分。

如何確定您要刪除的選項卡的名稱

  • 打開瀏覽器的開發者工具。
  • 單擊選擇元素按鈕
  • 在窗口中選擇你要刪除的Dolibarr選頂卡。
  • 在開發者工具中查看 tab 屬性

 

用您的選項卡替換選項卡

只需執行「添加您自己的選項卡」和「刪除現有選項卡」步驟。如果添加的選項卡標題與刪除的選項卡標題相同,則錯覺將是完美的。

在自己的頁面中顯示選項卡

有關如何在自己的頁面中顯示選項卡的更多信息,請參閱 模塊開發