选项卡

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

Dolibarr选项卡系统

Dolibarr在由多个选项卡组成的视图中显示元素(发票、仓库、用户等)的信息。

您可以添加自己的选项卡、删除选项卡或替换现有选项卡。

添加您自己的选项卡

1) 首先,您需要确定要添加、删除或修改的选项卡所指向的对象类型及其代码“objectType”。以下是完整清单:

  • 'thirdparty' --------- 要在合作方视图中添加选项卡
  • 'intervention' ------ 要在现场服务视图中添加选项卡
  • 'supplier_order' --- 要在供应商订单视图中添加选项卡
  • 'supplier_invoice' - 要在供应商发票视图中添加选项卡
  • '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 属性

企业微信截图 20180829160108.png

要用您的选项卡替换选项卡

只需执行“添加您自己的选项卡”和“删除现有选项卡”步骤。如果添加的选项卡标题与删除的选项卡标题相同,则错觉将是完美的。

在自己的页面中显示选项卡

有关如何在自己的页面中显示选项卡的更多信息,请参阅 模块开发