From 65f707dea0c39349c26cb719ae12989db25b701c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Mar 2009 01:44:02 +0000 Subject: [PATCH] New: A module can add a new tab in third party view tabs --- ChangeLog | 1 + dev/skeletons/modMyModule.class.php | 14 ++++++-- htdocs/includes/modules/modAgenda.class.php | 40 +++++++++++---------- htdocs/lib/company.lib.php | 30 ++++++++++++---- htdocs/lib/fichinter.lib.php | 4 ++- htdocs/lib/fourn.lib.php | 8 +++-- htdocs/lib/invoice.lib.php | 8 +++-- htdocs/lib/member.lib.php | 16 +++++---- htdocs/lib/order.lib.php | 4 ++- htdocs/lib/product.lib.php | 6 ++-- htdocs/lib/propal.lib.php | 8 +++-- 11 files changed, 94 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9617d2fc240..5b911507bd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -75,6 +75,7 @@ For developers: - Renamed all function dolibarr_xxx into dol_xxx to have same prefix everywhere. - Rewrite clone feature for supplier invoice to work like other clone features. - First change to manage a future feature "stock PMP value". +- A module can add a new tab in third party view tabs. ***** Changelog for 2.5 compared to 2.4 ***** diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 2e0c632ce76..29bfb516dd4 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,8 +90,18 @@ class modMyModule extends DolibarrModules //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); - // New pages on tabs + // Array to add new pages in new tabs $this->tabs = array('entity:Title:@mymodule:/mymodule/mynewtab.php?id=__ID__'); + // where entity can be + // '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 + // 'propal' to add a tab in propal view + // 'member' to add a tab in fundation member view // Boxes diff --git a/htdocs/includes/modules/modAgenda.class.php b/htdocs/includes/modules/modAgenda.class.php index 11c3743b89a..e0e04e30f1b 100644 --- a/htdocs/includes/modules/modAgenda.class.php +++ b/htdocs/includes/modules/modAgenda.class.php @@ -60,32 +60,36 @@ class modAgenda extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='calendar'; - + // Dir //---- $this->dirs = array(); //$this->dirs[0] = DOL_DATA_ROOT.'/mymodule; //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; - + // Config pages //------------- $this->config_page_url = array("agenda.php"); - + // Dependancies //------------- $this->depends = array(); $this->requiredby = array(); $this->langfiles = array("companies"); - + // Constantes //----------- $this->const = array(); - - // Boites - //------- + + // New pages on tabs + // ----------------- + $this->tabs = array(); + + // Boxes + //------ $this->boxes = array(); $this->boxes[0][1] = "box_actions.php"; - + // Permissions //------------ $this->rights = array(); @@ -99,7 +103,7 @@ class modAgenda extends DolibarrModules // $this->rights[$r][4] Niveau 1 pour nommer permission dans code // $this->rights[$r][5] Niveau 2 pour nommer permission dans code // $r++; - + $this->rights[$r][0] = 2401; $this->rights[$r][1] = 'Read actions/tasks linked to his account'; $this->rights[$r][2] = 'r'; @@ -107,7 +111,7 @@ class modAgenda extends DolibarrModules $this->rights[$r][4] = 'myactions'; $this->rights[$r][5] = 'read'; $r++; - + $this->rights[$r][0] = 2402; $this->rights[$r][1] = 'Create/modify/delete actions/tasks linked to his account'; $this->rights[$r][2] = 'w'; @@ -115,7 +119,7 @@ class modAgenda extends DolibarrModules $this->rights[$r][4] = 'myactions'; $this->rights[$r][5] = 'create'; $r++; - + $this->rights[$r][0] = 2403; $this->rights[$r][1] = 'Read actions/tasks of others'; $this->rights[$r][2] = 'r'; @@ -123,7 +127,7 @@ class modAgenda extends DolibarrModules $this->rights[$r][4] = 'allactions'; $this->rights[$r][5] = 'read'; $r++; - + $this->rights[$r][0] = 2405; $this->rights[$r][1] = 'Create/modify/delete actions/tasks of others'; $this->rights[$r][2] = 'w'; @@ -135,10 +139,10 @@ class modAgenda extends DolibarrModules // Menus //------ $r=0; - + $this->menu[$r]=array('fk_menu'=>0,'type'=>'top','titre'=>'Agenda','mainmenu'=>'agenda','leftmenu'=>'0','url'=>'/comm/action/index.php','langs'=>'commercial','position'=>100,'perms'=>'$user->rights->agenda->myactions->read','target'=>'','user'=>0); $r++; - + // Exports //-------- $r=0; @@ -151,7 +155,7 @@ class modAgenda extends DolibarrModules // $this->export_sql[$r] Requete sql qui offre les donnees a l'export } - + /** * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. * Definit egalement les repertoires de donnees a creer pour ce module. @@ -159,10 +163,10 @@ class modAgenda extends DolibarrModules function init() { $sql = array(); - + return $this->_init($sql); } - + /** * \brief Fonction appelee lors de la desactivation d'un module. * Supprime de la base les constantes, boites et permissions du module. @@ -170,7 +174,7 @@ class modAgenda extends DolibarrModules function remove() { $sql = array(); - + return $this->_remove($sql); } diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index 651124a3099..d222bea55c2 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2006-2009 Laurent Destailleur * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2007 Patrick Raguin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,10 +27,10 @@ */ /** - * Enter description here... + * Return array of tabs to used on pages for third parties cards. * - * @param unknown_type $objsoc - * @return unknown + * @param $objsoc Object company shown + * @return array Array of tabs */ function societe_prepare_head($objsoc) { @@ -120,12 +120,30 @@ function societe_prepare_head($objsoc) $h++; } + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); + if (is_array($conf->tabs_modules['thirdparty'])) + { + $i=0; + foreach ($conf->tabs_modules['thirdparty'] as $value) + { + $values=split(':',$value); + if ($values[2]) $langs->load($values[2]); + $head[$h][0] = eregi_replace('__ID__',$objsoc->id,$values[3]); + $head[$h][1] = $langs->trans($values[1]); + $head[$h][2] = 'tab'.$values[1]; + $h++; + } + } + return $head; } /** - * Enter description here... + * Return array of tabs to used on page * * @param unknown_type $objsoc * @return unknown diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index 0fdbd460a4c..7930e72a3ab 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -68,7 +68,9 @@ function fichinter_prepare_head($fichinter) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['intervention'])) { $i=0; diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index d718ce92c70..794605e9197 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -55,7 +55,9 @@ function facturefourn_prepare_head($fac) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['supplier_invoice'])) { $i=0; @@ -114,7 +116,9 @@ function ordersupplier_prepare_head($commande) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['supplier_order'])) { $i=0; diff --git a/htdocs/lib/invoice.lib.php b/htdocs/lib/invoice.lib.php index df83af24279..8deb714aa40 100644 --- a/htdocs/lib/invoice.lib.php +++ b/htdocs/lib/invoice.lib.php @@ -31,7 +31,7 @@ function facture_prepare_head($fac) global $langs, $conf; $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'compta'; @@ -73,7 +73,9 @@ function facture_prepare_head($fac) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['invoice'])) { $i=0; @@ -87,7 +89,7 @@ function facture_prepare_head($fac) $h++; } } - + return $head; } diff --git a/htdocs/lib/member.lib.php b/htdocs/lib/member.lib.php index 4cbb16543d7..b45fe189216 100644 --- a/htdocs/lib/member.lib.php +++ b/htdocs/lib/member.lib.php @@ -28,19 +28,19 @@ function member_prepare_head($member) { global $langs, $conf, $user; - + $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$member->id; $head[$h][1] = $langs->trans("MemberCard"); $head[$h][2] = 'general'; $h++; - + if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) { $langs->load("ldap"); - + $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$member->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; @@ -54,7 +54,7 @@ function member_prepare_head($member) $head[$h][2] = 'subscription'; $h++; } - + $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$member->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; @@ -65,7 +65,9 @@ function member_prepare_head($member) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['member'])) { $i=0; @@ -79,7 +81,7 @@ function member_prepare_head($member) $h++; } } - + return $head; } diff --git a/htdocs/lib/order.lib.php b/htdocs/lib/order.lib.php index bca416a1e7d..3f9e5529005 100644 --- a/htdocs/lib/order.lib.php +++ b/htdocs/lib/order.lib.php @@ -90,7 +90,9 @@ function commande_prepare_head($commande) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['order'])) { $i=0; diff --git a/htdocs/lib/product.lib.php b/htdocs/lib/product.lib.php index adba6e50ed6..5eb4bd8e437 100644 --- a/htdocs/lib/product.lib.php +++ b/htdocs/lib/product.lib.php @@ -23,7 +23,7 @@ * \brief Ensemble de fonctions de base pour le module produit et service * \ingroup product * \version $Id$ - * + * * Ensemble de fonctions de base de dolibarr sous forme d'include */ @@ -118,7 +118,9 @@ function product_prepare_head($product, $user) } } - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['product'])) { $i=0; diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index dbc12ae1eea..925b276250f 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -22,7 +22,7 @@ * \brief Ensemble de fonctions de base pour le module propal * \ingroup propal * \version $Id$ - * + * * Ensemble de fonctions de base de dolibarr sous forme d'include */ @@ -86,7 +86,9 @@ function propal_prepare_head($propal) $head[$h][2] = 'info'; $h++; - // More tabs from modules + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:MyModule:@mymodule:/dolibarr/mymodule/mypage.php?id=__ID__'); if (is_array($conf->tabs_modules['propal'])) { $i=0; @@ -100,7 +102,7 @@ function propal_prepare_head($propal) $h++; } } - + return $head; }