From 2804ef22524bf42503247f72aed8203d9dc97e38 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 8 Jul 2012 14:18:40 +0200 Subject: [PATCH] New: classify billed order if invoice billed (workflow manager) --- htdocs/admin/workflow.php | 1 + htdocs/core/class/commonobject.class.php | 2 +- ...ce_20_modWorkflow_WorkflowManager.class.php | 18 ++++++++++++++++++ htdocs/langs/en_US/workflow.lang | 3 ++- htdocs/langs/fr_FR/workflow.lang | 3 ++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 590ab54c754..412eff9395b 100755 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -83,6 +83,7 @@ $workflow=array( ), 'order' => array( 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_ORDER') + ,'invoice' => array('WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER') ), 'invoice' => array ( 'order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE') diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b37cfecbd2a..53a1964406a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1673,7 +1673,7 @@ abstract class CommonObject else if ($justtarget) { $sql.= "fk_target = '".$targetid."' AND targettype = '".$targettype."'"; - if ($withsourcetype) $sql.= "AND sourcetype = '".$sourcetype."'"; + if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'"; } } else diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 757004dc378..3ba4b5b8248 100755 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -148,6 +148,24 @@ class InterfaceWorkflowManager } } + // Order classify billed proposal + if ($action == 'BILL_PAYED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) + { + $object->fetchObjectLinked('','commande',$object->id,$object->element); + if (! empty($object->linkedObjects)) + { + foreach($object->linkedObjects['commande'] as $element) + { + $ret=$element->classifyBilled(); + } + } + return $ret; + } + } + return 0; } diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index b07b1018819..0495842ebd2 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -7,4 +7,5 @@ descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Create a customer order automatically after descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Create a customer invoice automatically after a commercial proposal is signed descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Create a customer invoice automatically after a contract is validated descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Create a customer invoice automatically after a customer order is closed -descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify billed the original proposal along with a customer order \ No newline at end of file +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify billed the original proposal along with a customer order +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify billed originals customer orders along with a customer invoice \ No newline at end of file diff --git a/htdocs/langs/fr_FR/workflow.lang b/htdocs/langs/fr_FR/workflow.lang index ca1546d6789..1cb2a349c9d 100644 --- a/htdocs/langs/fr_FR/workflow.lang +++ b/htdocs/langs/fr_FR/workflow.lang @@ -7,4 +7,5 @@ descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Créer une commande client automatiquement descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la signature d'une proposition commerciale descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la validation d'un contrat descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la cloture d'une commande client -descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classer facturée la proposition commerciale d'origine en même temps que la commande \ No newline at end of file +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classer facturée la proposition commerciale d'origine en même temps que la commande +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classer facturée la ou les commandes clients d'origine en même temps que la facture \ No newline at end of file