Optimized extensions related code.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 9 Feb 2010 13:06:55 +0000 (13:06 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 9 Feb 2010 13:06:55 +0000 (13:06 +0000)
applications/application.php
applications/customers.php
applications/dimensions.php
applications/generalledger.php
applications/inventory.php
applications/manufacturing.php
applications/setup.php
applications/suppliers.php

index cf8c7c39b2d957d8aedf08096ca4c8866578009d..291a78a256ec9a418d252eb085f9e330df791c06 100644 (file)
                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 '';
+               }
        }
 
 
index 1a385b9ef4d285224554d9dad07163311b4549ab..d99e8fbbb562d6d017a2302000419fa16b1fca82 100644 (file)
@@ -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();
        }
 }
 
index bf46ef8d53284c3f5dbb2f2051d9253ea5a271eb..0af8fc75d028f5b91f48b86271da01473baf5515 100644 (file)
@@ -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
index c227dffae1433c91112c99a205b4dfbfadfc3c57..70a022a0b46cd303a249b017b3212ffd6a8e8273 100644 (file)
@@ -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();
        }
 }
 
index feb820bad12e4bd4c46218cc9d72caec181bc620..c92e5d1bc9c34ba8bc029c0eb1a8ce265a3ce0ad 100644 (file)
@@ -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();
        }
 }
 
index 6892ecc290c4ac5a64e26946f0657438a42131ea..3c9c861fcd685f25270e7de0340b2cbc209dd0dd 100644 (file)
@@ -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();
        }
 }
 
index 3f1f652cba4224d20247fdbd3775c6d71f1d4601..9e681d24d4ab1d60f094ac21e19ed23aedc23d52 100644 (file)
@@ -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();
        }
 }
 
index 304c653c731a79c0c8169c7751eb7eb51d41e586..173a8c03ac386a5cb478816fe6d885fbc6bda392 100644 (file)
@@ -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();
        }
 }