選項卡

Revision as of 08:42, 25 September 2023 by ShengGang (talk | contribs)

Dolibarr選項卡

Dolibarr通過選項卡來顯示元素的信息。

可以添加、刪除或替換現存的選項卡

添加選項卡

1) 首先, 必須標識選項卡所涉及的對象類型及其對象類型代碼。這是完整的列表:

  • 'thirdparty' to add a tab in third party view
  • 'intervention' to add a tab in intervention view
  • 'supplier_order' to add a tab in supplier order view
  • 'supplier_invoice' to add a tab in supplier invoice view
  • 'invoice' to add a tab in customer invoice view
  • 'order' to add a tab in customer order view
  • 'product' to add a tab in product view
  • 'stock' to add a tab in stock view
  • 'propal' to add a tab in propal view
  • 'member' to add a tab in fundation member view
  • 'contract' to add a tab in contract view
  • 'user' to add a tab in user view
  • 'group' to add a tab in group view
  • 'contact' to add a tab in contact view
  • 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
  • 'member_stats', 'order_stats', 'supplier_order_stats', 'invoice_stats', 'supplier_invoice_stats', 'trip_stats', 'propal_stats' to add a tab in statistic view of elements.
  • 'member_admin', 'company_admin', 'product_admin' for admin pages

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) 測試新選項卡

刪除現在的選項卡

刪除選項卡的操作與添加選項卡相同,在模塊文件的tabs數組中使用以下語句:

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

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

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

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

 

替換選項卡

執行 "添加選項卡" 和 "刪除現在的選項卡"。如果新標籤的標題與刪除的標題相同,則錯覺是完美的。

將標籤顯示在自己的頁面中

更多關於如何在頁面中顯示標籤的信息在頁面上可用。 Module_development#The_tab_management