From edbff365515fbb3a2899ff0b9717c1596496aff0 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 9 Feb 2010 13:06:55 +0000 Subject: [PATCH] Optimized extensions related code. --- applications/application.php | 38 +++++++++++++++++++++++++++++++--- applications/customers.php | 13 ++---------- applications/dimensions.php | 17 ++------------- applications/generalledger.php | 15 +++----------- applications/inventory.php | 15 +++----------- applications/manufacturing.php | 13 ++---------- applications/setup.php | 15 ++++---------- applications/suppliers.php | 20 +++++++----------- 8 files changed, 59 insertions(+), 87 deletions(-) diff --git a/applications/application.php b/applications/application.php index cf8c7c39..291a78a2 100644 --- a/applications/application.php +++ b/applications/application.php @@ -116,12 +116,44 @@ function add_lapp_function($level, $label,$link="",$access='SA_OPEN') { $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access); - } - + } + function add_rapp_function($level, $label,$link="",$access='SA_OPEN') { $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access); - } + } + + function add_extensions() + { + global $installed_extensions, $path_to_root; + + foreach ($installed_extensions as $mod) + { + if (@$mod['active'] && isset($mod['entries'])) + foreach($mod['entries'] as $entry) { + if ($entry['tab_id'] == $this->id) + $this->add_rapp_function( + isset($entry['section']) ? $entry['section'] : 2, + $entry['title'], $path_to_root.'/'.$mod['path'].'/'.$entry['url'], + isset($entry["access"]) ? $entry["access"] : 'SA_OPEN' ); + } + } + } + // + // Helper returning link to report class added by extension module. + // + function report_class_url($class) + { + global $installed_extensions; + + // TODO : konwencja lub ? + $classno = 7; +// if (file_exists($path_to_root.'/'.$mod['path'].'/'.$entry['url'] +// .'/'.'reporting/reports_custom.php')) + return "reporting/reports_main.php?Class=".$class; +// else +// return ''; + } } diff --git a/applications/customers.php b/applications/customers.php index 1a385b9e..d99e8fbb 100644 --- a/applications/customers.php +++ b/applications/customers.php @@ -13,7 +13,6 @@ class customers_app extends application { function customers_app() { - global $installed_extensions; $this->application("orders", _($this->help_context = "&Sales")); $this->add_module(_("Transactions")); @@ -76,16 +75,8 @@ class customers_app extends application "sales/manage/sales_areas.php?", 'SA_SALESAREA'); $this->add_rapp_function(2, _("Credit &Status Setup"), "sales/manage/credit_status.php?", 'SA_CRSTATUS'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "orders") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } diff --git a/applications/dimensions.php b/applications/dimensions.php index bf46ef8d..0af8fc75 100644 --- a/applications/dimensions.php +++ b/applications/dimensions.php @@ -13,7 +13,6 @@ class dimensions_app extends application { function dimensions_app() { - global $installed_extensions; $dim = get_company_pref('use_dimension'); $this->application("proj", _($this->help_context = "&Dimensions"), $dim); @@ -35,22 +34,10 @@ class dimensions_app extends application $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Dimension &Tags"), "admin/tags.php?type=dimension", 'SA_DIMTAGS'); - - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "proj") - { - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } - } + + $this->add_extensions(); } } } - ?> \ No newline at end of file diff --git a/applications/generalledger.php b/applications/generalledger.php index c227dffa..70a022a0 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -13,7 +13,6 @@ class general_ledger_app extends application { function general_ledger_app() { - global $installed_extensions; $this->application("GL", _($this->help_context = "&Banking and General Ledger")); $this->add_module(_("Transactions")); @@ -47,7 +46,7 @@ class general_ledger_app extends application $this->add_rapp_function(1, _("Banking &Reports"), "reporting/reports_main.php?Class=5", 'SA_BANKREP'); $this->add_rapp_function(1, _("General Ledger &Reports"), - "reporting/reports_main.php?Class=6", 'SA_GLREP'); + "reporting/reports_main.php?Class="._("General Ledger"), 'SA_GLREP'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Bank &Accounts"), @@ -68,16 +67,8 @@ class general_ledger_app extends application "gl/manage/gl_account_types.php?", 'SA_GLACCOUNTGROUP'); $this->add_rapp_function(2, _("GL Account &Classes"), "gl/manage/gl_account_classes.php?", 'SA_GLACCOUNTCLASS'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "GL") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } diff --git a/applications/inventory.php b/applications/inventory.php index feb820ba..c92e5d1b 100644 --- a/applications/inventory.php +++ b/applications/inventory.php @@ -13,7 +13,6 @@ class inventory_app extends application { function inventory_app() { - global $installed_extensions; $this->application("stock", _($this->help_context = "&Items and Inventory")); $this->add_module(_("Transactions")); @@ -28,7 +27,7 @@ class inventory_app extends application $this->add_lapp_function(1, _("Inventory Item &Status"), "inventory/inquiry/stock_status.php?", 'SA_ITEMSSTATVIEW'); $this->add_rapp_function(1, _("Inventory &Reports"), - "reporting/reports_main.php?Class=2", 'SA_ITEMSTRANSVIEW'); + "reporting/reports_main.php?Class="._("Inventory"), 'SA_ITEMSTRANSVIEW'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Items"), @@ -55,16 +54,8 @@ class inventory_app extends application "inventory/purchasing_data.php?", 'SA_PURCHASEPRICING'); $this->add_rapp_function(3, _("Standard &Costs"), "inventory/cost_update.php?", 'SA_STANDARDCOST'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "stock") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } diff --git a/applications/manufacturing.php b/applications/manufacturing.php index 6892ecc2..3c9c861f 100644 --- a/applications/manufacturing.php +++ b/applications/manufacturing.php @@ -13,7 +13,6 @@ class manufacturing_app extends application { function manufacturing_app() { - global $installed_extensions; $this->application("manuf", _($this->help_context = "&Manufacturing")); $this->add_module(_("Transactions")); @@ -37,16 +36,8 @@ class manufacturing_app extends application "manufacturing/manage/bom_edit.php?", 'SA_BOM'); $this->add_lapp_function(2, _("&Work Centres"), "manufacturing/manage/work_centres.php?", 'SA_WORKCENTRES'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "manuf") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } diff --git a/applications/setup.php b/applications/setup.php index 3f1f652c..9e681d24 100644 --- a/applications/setup.php +++ b/applications/setup.php @@ -13,7 +13,6 @@ class setup_app extends application { function setup_app() { - global $installed_extensions; $this->application("system", _($this->help_context = "S&etup")); $this->add_module(_("Company Setup")); @@ -68,18 +67,12 @@ class setup_app extends application "admin/inst_lang.php?", 'SA_CREATELANGUAGE'); $this->add_rapp_function(2, _("Install/Activate &Extensions"), "admin/inst_module.php?", 'SA_CREATEMODULES'); + $this->add_rapp_function(2, _("Install/Activate &Themes"), + "admin/inst_theme.php?", 'SA_CREATEMODULES'); $this->add_rapp_function(2, _("Software &Upgrade"), "admin/inst_upgrade.php?", 'SA_SOFTWAREUPGRADE'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "system") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } diff --git a/applications/suppliers.php b/applications/suppliers.php index 304c653c..173a8c03 100644 --- a/applications/suppliers.php +++ b/applications/suppliers.php @@ -13,14 +13,18 @@ class suppliers_app extends application { function suppliers_app() { - global $installed_extensions; $this->application("AP", _($this->help_context = "&Purchases")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Purchase &Order Entry"), "purchasing/po_entry_items.php?NewOrder=Yes", 'SA_PURCHASEORDER'); $this->add_lapp_function(0, _("&Outstanding Purchase Orders Maintenance"), - "purchasing/inquiry/po_search.php?", 'SA_SUPPTRANSVIEW'); + "purchasing/inquiry/po_search.php?", 'SA_GRN'); + $this->add_lapp_function(0, _("Direct &GRN"), + "purchasing/po_entry_items.php?NewGRN=Yes", 'SA_GRN'); + $this->add_lapp_function(0, _("Direct &Invoice"), + "purchasing/po_entry_items.php?NewInvoice=Yes", 'SA_SUPPLIERINVOICE'); + $this->add_rapp_function(0, _("&Payments to Suppliers"), "purchasing/supplier_payment.php?", 'SA_SUPPLIERPAYMNT'); $this->add_rapp_function(0, "",""); @@ -46,16 +50,8 @@ class suppliers_app extends application $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Suppliers"), "purchasing/manage/suppliers.php?", 'SA_SUPPLIER'); - if (count($installed_extensions) > 0) - { - foreach ($installed_extensions as $mod) - { - if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "AP") - $this->add_rapp_function(2, $mod["title"], - "modules/".$mod["path"]."/".$mod["filename"]."?", - isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); - } - } + + $this->add_extensions(); } } -- 2.30.2