From c57063878d286c1589edb025ab67cb651bd55b9d Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis@dolibarr.fr> Date: Wed, 4 Apr 2012 09:24:20 +0200 Subject: [PATCH] New: add workflow module part for external modules --- dev/skeletons/modMyModule.class.php | 1 + htdocs/admin/workflow.php | 34 ++++++++++++++++++++--- htdocs/core/class/conf.class.php | 3 ++ htdocs/core/modules/modWorkflow.class.php | 2 +- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index f9901feb7bd..9cf6604ce9b 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -81,6 +81,7 @@ class modMyModule extends DolibarrModules // 'models' => 0, // Set this to 1 if module has its own models directory // 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module + // 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module // ); $this->module_parts = array(); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 00775ed3070..2132a059926 100755 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -77,10 +77,36 @@ print "</tr>\n"; clearstatcache(); $workflowcodes=array(); -if ($conf->propal->enabled && $conf->commande->enabled) $workflowcodes['WORKFLOW_PROPAL_AUTOCREATE_ORDER']='WORKFLOW_PROPAL_AUTOCREATE_ORDER'; -//if ($conf->propal->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_PROPAL_AUTOCREATE_INVOICE']='WORKFLOW_PROPAL_AUTOCREATE_INVOICE'; -//if ($conf->contrat->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_CONTRACT_AUTOCREATE_INVOICE']='WORKFLOW_CONTRACT_AUTOCREATE_INVOICE'; -if ($conf->commande->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_ORDER_AUTOCREATE_INVOICE']='WORKFLOW_ORDER_AUTOCREATE_INVOICE'; +$workflow=array( + 'order' => array( + 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_ORDER') + ), + 'invoice' => array ( + 'order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE') + //,'contract' => array('WORKFLOW_CONTRACT_AUTOCREATE_INVOICE') + //, 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_INVOICE') + ) +); +$workflow = array_merge($workflow, $conf->modules_parts['workflow']); + +foreach($workflow as $child => $parents) +{ + if ($conf->$child->enabled) + { + $langs->Load($child.'@'.$child); + + foreach($parents as $parent => $actions) + { + if ($conf->$parent->enabled) + { + foreach($actions as $action) + { + $workflowcodes[$action] = $action; + } + } + } + } +} if (count($workflowcodes) > 0) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 71cabf3f68d..3f1e3bf94a6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -401,6 +401,9 @@ class Conf // For backward compatibility $this->produit=$this->product; + $this->invoice=$this->facture; + $this->order=$this->commande; + $this->contract=$this->contrat; // Define menu manager in setup diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index f2cff187233..e1b1d128e2d 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -69,7 +69,7 @@ class modWorkflow extends DolibarrModules $this->dirs = array("/workflow/temp"); // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = 'workflow.php'; + $this->config_page_url = array('workflow.php'); // Dependencies $this->depends = array(); // List of modules id that must be enabled if this module is enabled -- GitLab